Returns a new tree of all intervals common to both self and other.
(self, other)
| 424 | return IntervalTree(set(self).union(other)) |
| 425 | |
| 426 | def intersection(self, other): |
| 427 | """ |
| 428 | Returns a new tree of all intervals common to both self and |
| 429 | other. |
| 430 | """ |
| 431 | ivs = set() |
| 432 | shorter, longer = sorted([self, other], key=len) |
| 433 | for iv in shorter: |
| 434 | if iv in longer: |
| 435 | ivs.add(iv) |
| 436 | return IntervalTree(ivs) |
| 437 | |
| 438 | def intersection_update(self, other): |
| 439 | """ |