MCPcopy Index your code
hub / github.com/RustPython/RustPython / _siftdown

Function _siftdown

Lib/heapq.py:221–233  ·  view source on GitHub ↗
(heap, startpos, pos)

Source from the content-addressed store, hash-verified

219# is the index of a leaf with a possibly out-of-order value. Restore the
220# heap invariant.
221def _siftdown(heap, startpos, pos):
222 newitem = heap[pos]
223 # Follow the path to the root, moving parents down until finding a place
224 # newitem fits.
225 while pos > startpos:
226 parentpos = (pos - 1) >> 1
227 parent = heap[parentpos]
228 if newitem < parent:
229 heap[pos] = parent
230 pos = parentpos
231 continue
232 break
233 heap[pos] = newitem
234
235# The child indices of heap index pos are already heaps, and we want to make
236# a heap at index pos too. We do this by bubbling the smaller child of

Callers 2

heappushFunction · 0.85
_siftupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected