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

Method extract_top

data_structures/heap/heap_generic.py:120–128  ·  view source on GitHub ↗

Return top item tuple (Calculated value, item) from heap and removes it as well if present

(self)

Source from the content-addressed store, hash-verified

118 return self.arr[0] if self.size else None
119
120 def extract_top(self) -> tuple | None:
121 """
122 Return top item tuple (Calculated value, item) from heap and removes it as well
123 if present
124 """
125 top_item_tuple = self.get_top()
126 if top_item_tuple:
127 self.delete_item(top_item_tuple[0])
128 return top_item_tuple
129
130
131def test_heap() -> None:

Callers

nothing calls this directly

Calls 2

get_topMethod · 0.95
delete_itemMethod · 0.95

Tested by

no test coverage detected