-
Notifications
You must be signed in to change notification settings - Fork 0
PriorityQueue
Sean Raven edited this page Oct 28, 2015
·
1 revision
A Priority Queue is a queue in which the pop() operation removes the
"largest" item in the list, defined either by its natural ordering or a
comparator.
Certain algoritims (particularly Dijkstra's) may require changing the priority
of an item in the queue. C++'s priority_queue is simply a wrapper for
make_heap, push_heap, and pop_heap (defined in #include<algorithm>).
When using such algorithms, it is easiest to just use those functions directly,
by modifying the priority in-place and calling make_heap.
Java does not support such re-prioritizing, so you must first remove the item
from the queue, change its priority, then add it again.