public interface PriorityQueue<Element extends java.lang.Comparable>
A PriorityQueue represents an unbounded queue of items arranged in some
priority order.
This queue orders items according to their natural order
(see
Comparable).
A priority queue does not permit null elements. A priority queue
also does not permit insertion of non-comparable objects (doing so may
result in ClassCastException).
The head of this queue is the greatest element with respect to the
specified ordering.
If multiple elements are tied for greatest value, the head is one of those
elements -- ties are broken arbitrarily.
The queue retrieval operations dequeue and peek access the element at the
head of the queue.
All implementations must include an iterator()
method
to allow clients to use for-each loop to traverse the elements of the
PriorityQueue in order.
Method Summary | |
---|---|
void |
clear()
Removes all elements from the priority queue. |
Element |
dequeue()
Retrieves and removes the head of this queue. |
void |
enqueue(Element element)
Adds the specified element to this priority queue. |
boolean |
isEmpty()
Indicates whether or not the queue is empty. |
Element |
peek()
Retrieves, but does not remove, the head of this queue. |
int |
size()
Returns the number of elements currently in this queue. |
Methods inherited from interface java.lang.Iterable |
---|
iterator |
Method Detail |
---|
void clear()
Element peek()
Element dequeue()
void enqueue(Element element)
element
- is an item to be enqueuedint size()
boolean isEmpty()