[
https://issues.apache.org/jira/browse/TS-4537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15331036#comment-15331036
]
Thomas Jackson commented on TS-4537:
------------------------------------
We have to rewrite the index for the remaining either way (since this is
intentionally removing an item). I originally used the bubble down, but it
only updates the index if it sorts the items.
On Jun 14, 2016 6:37 PM, "ASF GitHub Bot (JIRA)" <[email protected]> wrote:
[
https://issues.apache.org/jira/browse/TS-4537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15330981#comment-15330981
]
ASF GitHub Bot commented on TS-4537:
------------------------------------
Github user masaori335 commented on a diff in the pull request:
https://github.com/apache/trafficserver/pull/708#discussion_r67087190
--- Diff: lib/ts/PriorityQueue.h ---
@@ -115,6 +117,22 @@ PriorityQueue<T, Comp>::pop()
template <typename T, typename Comp>
void
+PriorityQueue<T, Comp>::erase(PriorityQueueEntry<T> *entry)
+{
+ if (empty()) {
+ return;
+ }
+
+ _v.remove_index(entry->index);
+
+ // Correct all of the indexes for the removed items
+ for (unsigned int idx = entry->index; idx < _v.length(); idx++) {
--- End diff --
IMO, we can avoid rewriting all of the indexes because this is Binary
Heap.
How about this like what we're doing in `PriorityQueue<T, Comp>::pop()`
?
```
_v[entry->index] = _v[_v.length() - 1];
_v.pop();
_bubble_down(entry->index);
```
method-- we probably should have one :)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
> Add erase to PriorityQueue
> --------------------------
>
> Key: TS-4537
> URL: https://issues.apache.org/jira/browse/TS-4537
> Project: Traffic Server
> Issue Type: New Feature
> Reporter: Thomas Jackson
> Assignee: Thomas Jackson
> Fix For: 7.0.0
>
>
> The priorityqueue (really more of a sorted list...) doesn't have an erase
> method-- we probably should have one :)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)