Add ability to pass in comparator instead of making keys implement Comparable
rnikander opened this issue · 0 comments
rnikander commented
Maybe I'm missing something, but it seems like with some algorithms there is an advantage to passing in the function that does the comparison. As an example, I'm computing line segment intersections with a sweep line algorithm. I wanted to try your BTree
or SortedSet
because my current data structure (a red black tree) seems slow. But it's difficult to use these classes because I need a comparison function that uses state from the algorithm: the sweep line, current point, etc. I can get around this by adding a reference to every single element in the SortedSet
, but they were just integers, so that's at least doubled the storage needed per element.