I have a priority queue of events, but sometimes the event priorities change, so I'd like to maintain iterators from the event requesters into the heap. If the priority changes, I'd like the heap to be adjusted in log(n) time. I will always have exactly one iterator pointing to each element in the heap.
views:
609answers:
3
+2
Q:
Is there a heap class in C++ that supports changing the priority of elements other than the head?
+1
A:
That sounds like you need more indirection. Store pointer to the events in the priority queue instead. When priority of some element of the queue changes, remove it and reinsert.
wilx
2009-05-29 19:17:26
Thanks, if I end up having to roll my own, I'll use that snippet to start.
Neil G
2009-05-29 20:52:25
ended up going with this solution
Neil G
2009-06-01 07:25:15
A:
A warning here is that you end up with unstable event sorting, i.e. ordering of the events with the same priority is undefined (read 'they will be reordered'.)
Nikolai N Fetissov
2009-05-29 19:39:07