alexbol99 / flatten-interval-tree

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

Fast way to check if interval collides collides i.e intersects([low, high]): boolean #26

Closed SudoPlz closed 3 years ago

SudoPlz commented 3 years ago

Hey there,

I'm looking for a way to quickly tell if a given interval collides with even 1 of the existing intervals within a tree. I assume tree.search keeps looking for all the other intervals within the input query interval (in order to return them), but I'm looking for a method that's faster than that, and just returns if it even encounters just 1 interval that collides with the input (query) interval.

Something like tree.intersects([low, high]): boolean Is there any way to do that (since I'm not interested about the values and I'm not interested in getting any of the intervals within the range, just the information of wether more than 1 exists or not).

I hope my question makes sense.

Thanks

alexbol99 commented 3 years ago

Hi, @SudoPlz ,

Yes, it makes sense. I will implement your request

alexbol99 commented 3 years ago

Hi @SudoPlz ,

I added method intersect_any in version v1.0.14

Thank you for your contribution to this project, Alex

SudoPlz commented 3 years ago

You're so kind. Thank you so much for adding that and for all your great work!