DataStructures
Interface PriorityQueue<E extends java.lang.Comparable<? super E>>

Type Parameters:
E - the type of elements held in this queue
All Known Implementing Classes:
BinaryHeap, StrictBinaryHeap

public interface PriorityQueue<E extends java.lang.Comparable<? super E>>

Interface for a priority queue of elements of type E.

Elements of type E must implement the Comparable interface in their defining class or in some superclass.

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.

Author:
Peter Williams
See Also:
Comparable

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

Method Detail

isEmpty

boolean isEmpty()
Indicates the status of the queue.

Returns:
true if the queue is empty.

size

int size()
Returns the current size of the queue

Returns:
the current size of the queue

add

void add(E item)
Adds an item to the queue.

Parameters:
item - the item to be added.

remove

E remove()
Removes an item of highest priority from the queue.

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