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

Method discard

sortedcontainers/sortedset.py:403–422  ·  view source on GitHub ↗

Remove `value` from sorted set if it is a member. If `value` is not a member, do nothing. Runtime complexity: `O(log(n))` -- approximate. >>> ss = SortedSet([1, 2, 3, 4, 5]) >>> ss.discard(5) >>> ss.discard(0) >>> ss == set([1, 2, 3, 4]) Tru

(self, value)

Source from the content-addressed store, hash-verified

401
402
403 def discard(self, value):
404 """Remove `value` from sorted set if it is a member.
405
406 If `value` is not a member, do nothing.
407
408 Runtime complexity: `O(log(n))` -- approximate.
409
410 >>> ss = SortedSet([1, 2, 3, 4, 5])
411 >>> ss.discard(5)
412 >>> ss.discard(0)
413 >>> ss == set([1, 2, 3, 4])
414 True
415
416 :param value: `value` to discard from sorted set
417
418 """
419 _set = self._set
420 if value in _set:
421 _set.remove(value)
422 self._list.remove(value)
423
424 _discard = discard
425

Callers 1

test_discardFunction · 0.95

Calls 1

removeMethod · 0.45

Tested by 1

test_discardFunction · 0.76