File tree 1 file changed +6
-7
lines changed
1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -85,20 +85,19 @@ cdef class IntervalTree(IntervalMixin):
85
85
def is_overlapping(self):
86
86
"""
87
87
Determine if the IntervalTree contains overlapping intervals.
88
+ Cached as self._is_overlapping.
88
89
"""
89
90
if self._is_overlapping is not None:
90
91
return self._is_overlapping
91
92
92
93
# <= when both sides closed since endpoints can overlap
93
94
op = le if self.closed == 'both' else lt
94
95
95
- self._is_overlapping = False
96
- for previous, current in zip(self.left_sorter, self.left_sorter[1:]):
97
- # overlap if start of current interval < end of previous interval
98
- # (previous in terms of sorted order by left/start side)
99
- if op(self.left[current], self.right[previous]):
100
- self._is_overlapping = True
101
- break
96
+ # overlap if start of current interval < end of previous interval
97
+ # (current and previous in terms of sorted order by left/start side)
98
+ current = self.left[self.left_sorter[1:]]
99
+ previous = self.right[self.left_sorter[:-1]]
100
+ self._is_overlapping = bool(op(current, previous).any())
102
101
103
102
return self._is_overlapping
104
103
You can’t perform that action at this time.
0 commit comments