w8r / splay-tree

Fast splay-tree data structure
https://npm.runkit.com/splaytree
114 stars 18 forks source link

Have remove use comparator for compare #2

Closed Kaisle closed 6 years ago

Kaisle commented 6 years ago

When removing, the test for equality should use the comparator. This allows you to use objects as keys.

Example:

const t = new Tree(function(a,b){return a.c < b.c;}); t.insert({c: 1, d: 2}); t.remove({c: 1, d: 2}); console.log(t.keys()); // prints [ { c: 1, d: 2 } ], should print []

w8r commented 6 years ago

Thanks a lot!