CITS2200
Interface PriorityQueue<E>


public interface PriorityQueue<E>

PriorityQueue interface.


Method Summary
 E dequeue()
          remove the item at the front of the queue (the element with the highest priority that has been there the longest)
 void enqueue(E a, int priority)
          insert an item at the back into the queue with a given priority
 E examine()
          examine the item at the front of the queue (the element with the highest priority that has been in the queue the longest)
 boolean isEmpty()
          test whether the queue is empty
 Iterator iterator()
          return a DAT.Iterator to examine all the elements in the PriorityQueue
 

Method Detail

isEmpty

boolean isEmpty()
test whether the queue is empty

Returns:
true if the prioirty queue is empty, false otherwise

enqueue

void enqueue(E a,
             int priority)
             throws IllegalValue
insert an item at the back into the queue with a given priority

Parameters:
a - the item to insert
priority - the priority of the element
Throws:
IllegalValue - if the priority is not in a valid range

examine

E examine()
          throws Underflow
examine the item at the front of the queue (the element with the highest priority that has been in the queue the longest)

Returns:
the first item,
Throws:
Underflow - if the queue is empty

dequeue

E dequeue()
          throws Underflow
remove the item at the front of the queue (the element with the highest priority that has been there the longest)

Returns:
the removed item
Throws:
Underflow - if the queue is empty

iterator

Iterator iterator()
return a DAT.Iterator to examine all the elements in the PriorityQueue

Returns:
an Iterator pointing to before the first item