IsEmpty: return true if
a priority queue is empty.
ExtractMin: return the
element with the minimum cost from a priority queue
Insert: insert an element into a priority queue
Update: update an existing element in a priority
queue
Example
#include “PriorityQueue.h”
CTypedPtrHeap<Node> pq; //initialize the priority queue
of
integers pq to be empty;
pq.IsEmpty(); //return true;
Node
*a,*b,*c; //We assume that the costs in increasing order are a, b, c
pq.Insert(a); // pq=(a)
pq.Insert(b); // pq=(a,b)
pq.Insert(c); // pq=(a,b,c)
Node* d=pq.ExtractMin(); // pq=(b,c); d=a;
//modify
c’s key to be the smallest one
pq.Update(c); // update
pq to reflect c is modifed;
pq=(c, b);
pq.IsEmpty(); //return false;