Replace self[pos] with a lower value item and then reheapify
(self, pos, newitem)
| 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" |
no outgoing calls
no test coverage detected