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

Method clear

data_structures/heap/randomized_heap.py:175–186  ·  view source on GitHub ↗

Clear the heap. >>> rh = RandomizedHeap([3, 1, 3, 7]) >>> rh.clear() >>> rh.pop() Traceback (most recent call last): ... IndexError: Can't get top element for the empty heap.

(self)

Source from the content-addressed store, hash-verified

173 return self._root.value
174
175 def clear(self) -> None:
176 """
177 Clear the heap.
178
179 >>> rh = RandomizedHeap([3, 1, 3, 7])
180 >>> rh.clear()
181 >>> rh.pop()
182 Traceback (most recent call last):
183 ...
184 IndexError: Can't get top element for the empty heap.
185 """
186 self._root = None
187
188 def to_sorted_list(self) -> list[Any]:
189 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected