Interface PriorityQueue

All Known Implementing Classes:
BinaryHeap

public interface PriorityQueue

Interface for a priority queue.

The remove method returns an item of highest priority from the queue.

If distinct items are of the same priority, an implementation is not obliged to return them in any particular order, unless it declares otherwise.

See Also:
Comparable

Method Summary
 void add(java.lang.Comparable item)
          Adds an item to the queue.
 boolean isEmpty()
          Indicates the status of the queue.
 java.lang.Comparable remove()
          Removes an item of highest priority from the queue.
 int size()
          Returns the current size of the queue
 

Method Detail

isEmpty

public boolean isEmpty()
Indicates the status of the queue.

Returns:
true if the queue is empty.

size

public int size()
Returns the current size of the queue

Returns:
the current size of the queue

add

public void add(java.lang.Comparable item)
Adds an item to the queue.

Parameters:
item - the item to be added.

remove

public java.lang.Comparable remove()
Removes an item of highest priority from the queue.

Returns:
an item of highest priority.
Throws:
NoSuchElementException - if the queue is empty.