10.3.4. Priority Queues

A priority queue is another abstract data type where each item in the queue has a priority. The type and operations are as follows.

PriorityQueue

An object of type PriorityQueue contains a collection of (item, priority) pairs. It is initially empty.

insert(x, p, q)

Insert item x with priority p into priority queue q.

remove(x, p, q)

Remove the pair with the smallest priority from q. Set x to the item and p to the priority of that pair. (Parameters x and p are out-parameters.)

isEmpty(q)

This returns true if q is empty.