Open mbhall88 opened 9 months ago
I would suggest splitting this functionality in two. I have a use case right now where I need to find all intervals in a given tree that overlap, which the first part of the above code does (which is what i will write), so splitting this up would yield an API like (pls excuse the quick psuedo code):
def get_all_overlaps(self):
for interval in self:
# TODO this will likely yield duplicate sets, so further refinement is needed
yield tree.overlap(interval)
# suggest 'pruning' as the action to the tree, but remove still fine
def prune_all_overlaps(self):
removed = []
for overlaps in self.get_all_overlaps():
for interval in overlaps:
removed.append(interval)
self.remove(interval)
return removed
I love this library. I use it A LOT!
One function I would love to have on an IntervalTree is
remove_overlaps
. This would remove anyway interval within the tree that overlaps with another.My current work around is effectively this