w8r / splay-tree

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

lowerBound / upperBound API? #22

Open nornagon opened 3 years ago

nornagon commented 3 years ago

Would be great to be able to fetch the largest key smaller than a given search value (and vice-versa)

w8r commented 3 years ago

you can do it with .range(lo, hi, fn) ?

nornagon commented 3 years ago

ah hm, i think that can only go one direction though? since it starts from lo and goes to hi. if i have a tree sorted in ascending order, there's no way to get the largest key smaller than k in O(log n), right? unless i'm misunderstanding the range functionality.