MCPcopy Index your code
hub / github.com/grantjenks/python-sortedcontainers / add

Method add

sortedcontainers/sortedset.py:341–359  ·  view source on GitHub ↗

Add `value` to sorted set. Runtime complexity: `O(log(n))` -- approximate. >>> ss = SortedSet() >>> ss.add(3) >>> ss.add(1) >>> ss.add(2) >>> ss SortedSet([1, 2, 3]) :param value: value to add to sorted set

(self, value)

Source from the content-addressed store, hash-verified

339
340
341 def add(self, value):
342 """Add `value` to sorted set.
343
344 Runtime complexity: `O(log(n))` -- approximate.
345
346 >>> ss = SortedSet()
347 >>> ss.add(3)
348 >>> ss.add(1)
349 >>> ss.add(2)
350 >>> ss
351 SortedSet([1, 2, 3])
352
353 :param value: value to add to sorted set
354
355 """
356 _set = self._set
357 if value not in _set:
358 _set.add(value)
359 self._list.add(value)
360
361 _add = add
362

Callers 15

test_stressFunction · 0.95
test_eqFunction · 0.95
test_neFunction · 0.95
test_addFunction · 0.95
test_countFunction · 0.95
runMethod · 0.45
runMethod · 0.45
runMethod · 0.45
runMethod · 0.45
runMethod · 0.45
addFunction · 0.45
stress_addFunction · 0.45

Calls

no outgoing calls

Tested by 13

test_stressFunction · 0.76
test_eqFunction · 0.76
test_neFunction · 0.76
test_addFunction · 0.76
test_countFunction · 0.76
stress_addFunction · 0.36
stress_addFunction · 0.36
stress_dupsFunction · 0.36
test_copyFunction · 0.36
test_copy_copyFunction · 0.36
test_repr_recursionFunction · 0.36
stress_addFunction · 0.36