MCPcopy Create free account
hub / github.com/grantjenks/python-sortedcontainers / remove

Method remove

sortedcontainers/sortedset.py:456–477  ·  view source on GitHub ↗

Remove `value` from sorted set; `value` must be a member. If `value` is not a member, raise :exc:`KeyError`. Runtime complexity: `O(log(n))` -- approximate. >>> ss = SortedSet([1, 2, 3, 4, 5]) >>> ss.remove(5) >>> ss == set([1, 2, 3, 4]) True

(self, value)

Source from the content-addressed store, hash-verified

454
455
456 def remove(self, value):
457 """Remove `value` from sorted set; `value` must be a member.
458
459 If `value` is not a member, raise :exc:`KeyError`.
460
461 Runtime complexity: `O(log(n))` -- approximate.
462
463 >>> ss = SortedSet([1, 2, 3, 4, 5])
464 >>> ss.remove(5)
465 >>> ss == set([1, 2, 3, 4])
466 True
467 >>> ss.remove(0)
468 Traceback (most recent call last):
469 ...
470 KeyError: 0
471
472 :param value: `value` to remove from sorted set
473 :raises KeyError: if `value` is not in sorted set
474
475 """
476 self._set.remove(value)
477 self._list.remove(value)
478
479
480 def difference(self, *iterables):

Callers 4

test_removeFunction · 0.95
__delitem__Method · 0.45
discardMethod · 0.45
popMethod · 0.45

Calls

no outgoing calls

Tested by 1

test_removeFunction · 0.76