fi.joensuu.cs.tra
Class PriorityQueue<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by java.util.PriorityQueue<E>
              extended by fi.joensuu.cs.tra.PriorityQueue<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Queue<E>

public class PriorityQueue<E>
extends java.util.PriorityQueue<E>

PriorityQueue is a convenience extension of java.util.PriorityQueue for relocation.

See Also:
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 java.util.Comparable).
PriorityQueue(java.util.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 java.util.Comparable).
PriorityQueue(int initialCapacity, java.util.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(java.util.SortedSet<? extends E> c)
          Creates a PriorityQueue containing the elements in the specified collection.
 
Method Summary
 boolean add(E o)
           
 void clear()
           
 java.util.Comparator<? super E> comparator()
           
 java.util.Iterator<E> iterator()
           
 E poll()
           
 boolean remove(java.lang.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

PriorityQueue

public PriorityQueue()
Creates a PriorityQueue with the default initial capacity (11) that orders its elements according to their natural ordering (using java.util.Comparable).


PriorityQueue

public PriorityQueue(int initialCapacity)
Creates a PriorityQueue with the specified initial capacity that orders its elements according to their natural ordering (using java.util.Comparable).

Parameters:
initialCapacity - the initial capacity for this priority queue.
Throws:
java.lang.IllegalArgumentException - if initialCapacity is less than 1

PriorityQueue

public PriorityQueue(int initialCapacity,
                     java.util.Comparator<? super E> comparator)
Creates a PriorityQueue with the specified initial capacity that orders its elements according to the specified comparator.

Parameters:
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.
Throws:
java.lang.IllegalArgumentException - if initialCapacity is less than 1

PriorityQueue

public PriorityQueue(java.util.Collection<? extends E> c)
Creates a PriorityQueue containing the elements in the specified collection. The priority queue has an initial capacity of 110% of the size of the specified collection or 1 if the collection is empty. If the specified collection is an instance of a java.util.SortedSet or is another PriorityQueue, the priority queue will be sorted according to the same comparator, or according to its elements' natural order if the collection is sorted according to its elements' natural order. Otherwise, the priority queue is ordered according to its elements' natural order.

Parameters:
c - the collection whose elements are to be placed into this priority queue.
Throws:
java.lang.ClassCastException - if elements of the specified collection cannot be compared to one another according to the priority queue's ordering.
java.lang.NullPointerException - if c or any element within it is null

PriorityQueue

public PriorityQueue(PriorityQueue<? extends E> c)
Creates a PriorityQueue containing the elements in the specified collection. The priority queue has an initial capacity of 110% of the size of the specified collection or 1 if the collection is empty. This priority queue will be sorted according to the same comparator as the given collection, or according to its elements' natural order if the collection is sorted according to its elements' natural order.

Parameters:
c - the collection whose elements are to be placed into this priority queue.
Throws:
java.lang.ClassCastException - if elements of the specified collection cannot be compared to one another according to the priority queue's ordering.
java.lang.NullPointerException - if c or any element within it is null

PriorityQueue

public PriorityQueue(java.util.SortedSet<? extends E> c)
Creates a PriorityQueue containing the elements in the specified collection. The priority queue has an initial capacity of 110% of the size of the specified collection or 1 if the collection is empty. This priority queue will be sorted according to the same comparator as the given collection, or according to its elements' natural order if the collection is sorted according to its elements' natural order.

Parameters:
c - the collection whose elements are to be placed into this priority queue.
Throws:
java.lang.ClassCastException - if elements of the specified collection cannot be compared to one another according to the priority queue's ordering.
java.lang.NullPointerException - if c or any element within it is null
Method Detail

add

public boolean add(E o)
Specified by:
add in interface java.util.Collection<E>
Overrides:
add in class java.util.PriorityQueue<E>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<E>
Overrides:
remove in class java.util.PriorityQueue<E>

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Overrides:
iterator in class java.util.PriorityQueue<E>

size

public int size()
Specified by:
size in interface java.util.Collection<E>
Overrides:
size in class java.util.PriorityQueue<E>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E>
Overrides:
clear in class java.util.PriorityQueue<E>

poll

public E poll()
Specified by:
poll in interface java.util.Queue<E>
Overrides:
poll in class java.util.PriorityQueue<E>

comparator

public java.util.Comparator<? super E> comparator()
Overrides:
comparator in class java.util.PriorityQueue<E>