Please note that the content of this book primarily consists of articles
available from Wikipedia or other free sources online.A priority queue
is an abstract data type in computer programming that supports the
following three operations: insertWithPriority: add an element to the
queue with an associated priority; getNext: remove the element from the
queue that has the highest priority, and return it (also known as
"PopElement(Off)", or "GetMinimum"); peekAtNext (optional): look at the
element with highest priority without removing it. One can imagine a
priority queue as a modified queue, but when one would get the next
element off the queue, the highest-priority one is retrieved first.
Stacks and queues may be modeled as particular kinds of priority queues.
In a stack, the priority of each inserted element is monotonically
increasing; thus, the last element inserted is always the first
retrieved. In a queue, the priority of each inserted element is
monotonically decreasing; thus, the first element inserted is always the
first retrieved.