/** * PriorityQueue demonstrates a priority queue using a Heap. * * @author Dr. Lewis * @author Dr. Chase * @version 1.0, 8/19/08 */ public class HeapPQ extends ArrayHeap> { private int size; /** * Creates an empty priority queue. */ public HeapPQ() { super(); size = 0; } /** * Adds the given element to this PriorityQueue. * * @param object the element to be added to the priority queue * @param priority the integer priority of the element to be added */ public void addElement (T object, int priority) { PriorityQueueNode node = new PriorityQueueNode (object, priority); super.addElement(node); size++; } /** * Removes the next highest priority element from this priority * queue and returns a reference to it. * * @return a reference to the next highest priority element in this queue */ public T removeNext() { PriorityQueueNode temp = (PriorityQueueNode)super.removeMin(); return temp.getElement(); } public int getSize(){ return size; } }