MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / insert

Method insert

data_structures/heap/skew_heap.py:159–171  ·  view source on GitHub ↗

Insert the value into the heap. >>> sh = SkewHeap() >>> sh.insert(3) >>> sh.insert(1) >>> sh.insert(3) >>> sh.insert(7) >>> list(sh) [1, 3, 3, 7]

(self, value: T)

Source from the content-addressed store, hash-verified

157 return iter(result)
158
159 def insert(self, value: T) -> None:
160 """
161 Insert the value into the heap.
162
163 >>> sh = SkewHeap()
164 >>> sh.insert(3)
165 >>> sh.insert(1)
166 >>> sh.insert(3)
167 >>> sh.insert(7)
168 >>> list(sh)
169 [1, 3, 3, 7]
170 """
171 self._root = SkewNode.merge(self._root, SkewNode(value))
172
173 def pop(self) -> T | None:
174 """

Callers 2

__init__Method · 0.95
__iter__Method · 0.95

Calls 2

SkewNodeClass · 0.85
mergeMethod · 0.45

Tested by

no test coverage detected