|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.PriorityQueue<E>
fi.joensuu.cs.tra.PriorityQueue<E>
public class PriorityQueue<E>
PriorityQueue is a convenience extension of java.util.PriorityQueue for relocation. PriorityQueue arranges the elements according to their natural order. The elements must implement the interface java.util.Comparable or a java.util.Comparator must be provided for the constructor. For example
PriorityQueuewould producepq = new PriorityQueue (); pq.add("foobar"); pq.add("tra"); pq.add("priorityqueue"); pq.add("et cetera"); String polled; while ((polled = pq.poll()) != null) System.out.println(polled);
et cetera foobar priorityqueue traWith Strings it is worth noting that the sorting is case sensitive so that Strings starting with capital letters take precedence.
PriorityQueue,
Serialized Form| Constructor Summary | |
|---|---|
PriorityQueue()
Creates a PriorityQueue with the default initial capacity (11) that orders its elements according to their natural ordering (using Comparable). |
|
PriorityQueue(Collection<? extends E> c)
Creates a PriorityQueue containing the elements in the specified collection. |
|
PriorityQueue(int initialCapacity)
Creates a PriorityQueue with the specified initial capacity that orders its elements according to their natural ordering (using Comparable). |
|
PriorityQueue(int initialCapacity,
Comparator<? super E> comparator)
Creates a PriorityQueue with the specified initial capacity that orders its elements according to the specified comparator. |
|
PriorityQueue(PriorityQueue<? extends E> c)
Creates a PriorityQueue containing the elements in the specified collection. |
|
PriorityQueue(SortedSet<? extends E> c)
Creates a PriorityQueue containing the elements in the specified collection. |
|
| Method Summary | |
|---|---|
boolean |
add(E o)
|
void |
clear()
|
Comparator<? super E> |
comparator()
|
Iterator<E> |
iterator()
|
E |
poll()
|
boolean |
remove(Object o)
|
int |
size()
|
| Methods inherited from class java.util.PriorityQueue |
|---|
offer, peek |
| Methods inherited from class java.util.AbstractQueue |
|---|
addAll, element, remove |
| Methods inherited from class java.util.AbstractCollection |
|---|
contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
|---|
contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public PriorityQueue()
Comparable).
public PriorityQueue(int initialCapacity)
Comparable).
initialCapacity - the initial capacity for this priority queue.
IllegalArgumentException - if initialCapacity is less
than 1
public PriorityQueue(int initialCapacity,
Comparator<? super E> comparator)
initialCapacity - the initial capacity for this priority queue.comparator - the comparator used to order this priority queue.
If null then the order depends on the elements' natural
ordering.
IllegalArgumentException - if initialCapacity is less
than 1public PriorityQueue(Collection<? extends E> c)
c - the collection whose elements are to be placed
into this priority queue.
ClassCastException - if elements of the specified collection
cannot be compared to one another according to the priority
queue's ordering.
NullPointerException - if c or any element within it
is nullpublic PriorityQueue(PriorityQueue<? extends E> c)
c - the collection whose elements are to be placed
into this priority queue.
ClassCastException - if elements of the specified collection
cannot be compared to one another according to the priority
queue's ordering.
NullPointerException - if c or any element within it
is nullpublic PriorityQueue(SortedSet<? extends E> c)
c - the collection whose elements are to be placed
into this priority queue.
ClassCastException - if elements of the specified collection
cannot be compared to one another according to the priority
queue's ordering.
NullPointerException - if c or any element within it
is null| Method Detail |
|---|
public boolean add(E o)
add in interface Collection<E>add in class PriorityQueue<E>public boolean remove(Object o)
remove in interface Collection<E>remove in class PriorityQueue<E>public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class PriorityQueue<E>public int size()
size in interface Collection<E>size in class PriorityQueue<E>public void clear()
clear in interface Collection<E>clear in class PriorityQueue<E>public E poll()
poll in interface Queue<E>poll in class PriorityQueue<E>public Comparator<? super E> comparator()
comparator in class PriorityQueue<E>
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||