chaimleib / intervaltree

A mutable, self-balancing interval tree. Queries may be by point, by range overlap, or by range containment.
Apache License 2.0
636 stars 108 forks source link

Chop with Interval #100

Open mbhall88 opened 4 years ago

mbhall88 commented 4 years ago

I was wondering whether you think that adding the ability to chop an IntervalTree with an Interval would be possible?

I find myself having to do things like this regularly

iv = Interval(1, 4)
tree.chop(iv.begin, iv.end)

It would nice to be able to do

iv = Interval(1, 4)
tree.chop(iv)
avishaan commented 3 years ago

Ah, I was looking for something similar. I'm probably just going to create my own helper func to make this easier for me. I'm not sure if this library is still seeing active updates but if so, I don't mind making a test covered PR with this feature implemented

davidaknowles commented 1 year ago

Relatedly, I'd like to be able to chop one interval tree out of another. I don't know the algorithms enough to know if this would actually be more efficient than just looping over the intervals in the second tree however (what I'm currently doing).