MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __bool__

Method __bool__

data_structures/heap/skew_heap.py:125–139  ·  view source on GitHub ↗

Check if the heap is not empty. >>> sh = SkewHeap() >>> bool(sh) False >>> sh.insert(1) >>> bool(sh) True >>> sh.clear() >>> bool(sh) False

(self)

Source from the content-addressed store, hash-verified

123 self.insert(item)
124
125 def __bool__(self) -> bool:
126 """
127 Check if the heap is not empty.
128
129 >>> sh = SkewHeap()
130 >>> bool(sh)
131 False
132 >>> sh.insert(1)
133 >>> bool(sh)
134 True
135 >>> sh.clear()
136 >>> bool(sh)
137 False
138 """
139 return self._root is not None
140
141 def __iter__(self) -> Iterator[T]:
142 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected