(self, i)
| 21 | |
| 22 | # 删除堆顶元素后, 交换堆尾和空堆顶的位置并实现元素的下沉 |
| 23 | def percDown(self, i): |
| 24 | while (i*2) <= self.currentSize: |
| 25 | mc = self.minChild(i) |
| 26 | if self.heapList[i] > self.heapList[mc]: |
| 27 | temp = self.heapList[i] |
| 28 | self.heapList[i] = self.heapList[mc] |
| 29 | self.heapList[mc] = temp |
| 30 | i = mc |
| 31 | |
| 32 | def minChild(self, i): |
| 33 | if i * 2 + 1 > self.currentSize: |