Replace an element in the queue with a new one.
(self, elt, new)
| 102 | return elt |
| 103 | |
| 104 | def update(self, elt, new): |
| 105 | """Replace an element in the queue with a new one.""" |
| 106 | # Replace |
| 107 | pos = self.d[elt] |
| 108 | self.h[pos] = new |
| 109 | del self.d[elt] |
| 110 | self.d[new] = pos |
| 111 | # Restore invariant by sifting up, then down |
| 112 | pos = self._siftup(pos) |
| 113 | self._siftdown(pos) |
| 114 | |
| 115 | def remove(self, elt): |
| 116 | """Remove an element from the queue.""" |
no test coverage detected