alexbol99 / flatten-interval-tree

Interval binary search tree
MIT License
41 stars 21 forks source link

Remove all items within a range #38

Open dipu-bd opened 2 years ago

dipu-bd commented 2 years ago

There is a method to remove a single item from the tree.

tree.remove(key, value)

I was wondering is there any method to remove all items within a range?

aphillipo commented 1 year ago

Would you want overlapping or fully within the range? You can probably do it with tree.map() which returns a new tree. It's definitely possible but I guess that would be quite inefficient as you've have to traverse the whole tree making the operation O(n).

dipu-bd commented 1 year ago

Yes, It would not be efficient. Deleting a range can be done in O(log n)