Performs changes required for swapping two elements in the heap
(self, i: int, j: int)
| 33 | return right if 0 < right < self.size else None |
| 34 | |
| 35 | def _swap(self, i: int, j: int) -> None: |
| 36 | """Performs changes required for swapping two elements in the heap""" |
| 37 | # First update the indexes of the items in index map. |
| 38 | self.pos_map[self.arr[i][0]], self.pos_map[self.arr[j][0]] = ( |
| 39 | self.pos_map[self.arr[j][0]], |
| 40 | self.pos_map[self.arr[i][0]], |
| 41 | ) |
| 42 | # Then swap the items in the list. |
| 43 | self.arr[i], self.arr[j] = self.arr[j], self.arr[i] |
| 44 | |
| 45 | def _cmp(self, i: int, j: int) -> bool: |
| 46 | """Compares the two items using default comparison""" |
no outgoing calls
no test coverage detected