MCPcopy Create free account
hub / github.com/chaimleib/intervaltree / add

Method add

intervaltree/intervaltree.py:314–334  ·  view source on GitHub ↗

Adds an interval to the tree, if not already present. Completes in O(log n) time.

(self, interval)

Source from the content-addressed store, hash-verified

312 self.boundary_table[end] -= 1
313
314 def add(self, interval):
315 """
316 Adds an interval to the tree, if not already present.
317
318 Completes in O(log n) time.
319 """
320 if interval in self:
321 return
322
323 if interval.is_null():
324 raise ValueError(
325 "IntervalTree: Null Interval objects not allowed in IntervalTree:"
326 " {0}".format(interval)
327 )
328
329 if not self.top_node:
330 self.top_node = Node.from_interval(interval)
331 else:
332 self.top_node = self.top_node.add(interval)
333 self.all_intervals.add(interval)
334 self._add_boundaries(interval)
335 append = add
336
337 def addi(self, begin, end, data=None):

Callers 14

test_insertFunction · 0.95
test_duplicate_insertFunction · 0.95
test_differenceFunction · 0.95
test_difference_operatorFunction · 0.95
test_add_ascendingMethod · 0.95
test_add_descendingMethod · 0.95
addiMethod · 0.95
updateMethod · 0.95
differenceMethod · 0.45
intersectionMethod · 0.45
chopMethod · 0.45
sliceMethod · 0.45

Calls 4

_add_boundariesMethod · 0.95
is_nullMethod · 0.80
formatMethod · 0.80
from_intervalMethod · 0.80

Tested by 6

test_insertFunction · 0.76
test_duplicate_insertFunction · 0.76
test_differenceFunction · 0.76
test_difference_operatorFunction · 0.76
test_add_ascendingMethod · 0.76
test_add_descendingMethod · 0.76