| 133 | |
| 134 | template <typename T, typename Comp> |
| 135 | void |
| 136 | PriorityQueue<T, Comp>::erase(PriorityQueueEntry<T> *entry) |
| 137 | { |
| 138 | if (empty()) { |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | // If the entry doesn't belong to this queue just return. |
| 143 | if (entry != _v[entry->index]) { |
| 144 | ink_assert(!in(entry)); |
| 145 | return; |
| 146 | } |
| 147 | |
| 148 | ink_release_assert(entry->index < _v.size()); |
| 149 | const uint32_t original_index = entry->index; |
| 150 | if (original_index != (_v.size() - 1)) { |
| 151 | // Move the erased item to the end to be popped off |
| 152 | _swap(original_index, _v.size() - 1); |
| 153 | // Fix the index before we pop it |
| 154 | _v[_v.size() - 1]->index = original_index; |
| 155 | _v.pop_back(); |
| 156 | _bubble_down(original_index); |
| 157 | _bubble_up(original_index); |
| 158 | } else { // Otherwise, we are already at the end, just pop |
| 159 | _v.pop_back(); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | template <typename T, typename Comp> |
| 164 | void |
no test coverage detected