MCPcopy Create free account
hub / github.com/ActiveState/code / reduce

Method reduce

recipes/Python/437116_Wrapper_class_heapq/recipe-437116.py:32–41  ·  view source on GitHub ↗

Replace self[pos] with a lower value item and then reheapify

(self, pos, newitem)

Source from the content-addressed store, hash-verified

30 pass
31
32 def reduce(self, pos, newitem):
33 "Replace self[pos] with a lower value item and then reheapify"
34 while pos > 0:
35 parentpos = (pos - 1) >> 1
36 parent = self[parentpos]
37 if parent <= newitem:
38 break
39 self[pos] = parent
40 pos = parentpos
41 self[pos] = newitem
42
43 def is_heap(self):
44 "Return True if the heap has the heap property; False otherwise"

Callers 6

recipe-579002.jsFile · 0.45
sum_Function · 0.45
recipe-437116.pyFile · 0.45
checkMethod · 0.45
checkMethod · 0.45
checkMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected