This
class is a Queue
implementation that orders its elements according to a specified
Comparator or orders Comparable
elements according to their compareTo( ) methods.
The head of the queue (the element removed by remove(
) and poll( )) is the smallest element
on the queue according to this ordering. The
Iterator return by the iterator(
) method is not guaranteed to iterate the elements in their
sorted order.
PriorityQueue is unbounded and prohibits
null elements. It is not threadsafe.
Figure 16-47. java.util.PriorityQueue<E>
public class
PriorityQueue<E> extends AbstractQueue<E> implements Serializable {
// Public Constructors
public
PriorityQueue ( );
public
PriorityQueue (int
initialCapacity );
public
PriorityQueue (SortedSet<? extends E>
c );
public
PriorityQueue (PriorityQueue<? extends E>
c );
public
PriorityQueue (Collection<? extends E>
c );
public
PriorityQueue (int
initialCapacity , Comparator<? super E>
comparator );
// Public Instance Methods
public Comparator<? super E>
comparator ( );
// Methods Implementing Collection
public Iterator<E>
iterator ( );
public boolean
remove (Object
o );
public int
size ( );
// Methods Implementing Queue
public boolean
offer (E
o );
public E
peek ( );
public E
poll ( );
// Public Methods Overriding AbstractQueue
public boolean
add (E
o );
public void
clear ( );
}