aicas logo Jamaica 3.4 release 8

java.util
Class PriorityQueue<E>

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

public class PriorityQueue<E>
extends AbstractQueue<E>
implements Serializable

Since:
1.5
See Also:
Serialized Form

Constructor Summary
PriorityQueue()
           
PriorityQueue(Collection<? extends E> c)
           
PriorityQueue(int cap)
           
PriorityQueue(int cap, Comparator<? super E> comp)
           
PriorityQueue(PriorityQueue<? extends E> c)
           
PriorityQueue(SortedSet<? extends E> c)
           
 
Method Summary
 boolean addAll(Collection<? extends E> c)
          Adds all of the elements in the specified collection to this queue.
 void clear()
          Removes all of the elements from this queue.
 Comparator<? super E> comparator()
           
 Iterator<E> iterator()
          Return an Iterator over this collection.
 boolean offer(E o)
          Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
 E peek()
          Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
 E poll()
          Retrieves and removes the head of this queue, or returns null if this queue is empty.
 boolean remove(Object o)
          Remove a single instance of an object from this collection (optional operation).
 int size()
          Return the number of elements in this collection.
 
Methods inherited from class java.util.AbstractQueue
add, 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()

PriorityQueue

public PriorityQueue(Collection<? extends E> c)

PriorityQueue

public PriorityQueue(int cap)

PriorityQueue

public PriorityQueue(int cap,
                     Comparator<? super E> comp)

PriorityQueue

public PriorityQueue(PriorityQueue<? extends E> c)

PriorityQueue

public PriorityQueue(SortedSet<? extends E> c)
Method Detail

clear

public void clear()
Description copied from class: AbstractQueue
Removes all of the elements from this queue. The queue will be empty after this call returns.

This implementation repeatedly invokes poll until it returns null.

Specified by:
clear in interface Collection<E>
Overrides:
clear in class AbstractQueue<E>
See Also:
Iterator.remove()

comparator

public Comparator<? super E> comparator()

iterator

public Iterator<E> iterator()
Description copied from class: AbstractCollection
Return an Iterator over this collection. The iterator must provide the hasNext and next methods and should in addition provide remove if the collection is modifiable.

Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in class AbstractCollection<E>
Returns:
an iterator

offer

public boolean offer(E o)
Description copied from interface: Queue
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to Queue.add(E), which can fail to insert an element only by throwing an exception.

Specified by:
offer in interface Queue<E>
Parameters:
o - the element to add
Returns:
true if the element was added to this queue, else false

peek

public E peek()
Description copied from interface: Queue
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.

Specified by:
peek in interface Queue<E>
Returns:
the head of this queue, or null if this queue is empty

poll

public E poll()
Description copied from interface: Queue
Retrieves and removes the head of this queue, or returns null if this queue is empty.

Specified by:
poll in interface Queue<E>
Returns:
the head of this queue, or null if this queue is empty

remove

public boolean remove(Object o)
Description copied from class: AbstractCollection
Remove a single instance of an object from this collection (optional operation). That is, remove one element e such that (o == null ? e == null : o.equals(e)), if such an element exists. This implementation obtains an iterator over the collection and iterates over it, testing each element for equality with the given object. If it is equal, it is removed by the iterator's remove method (thus this method will fail with an UnsupportedOperationException if the Iterator's remove method does). After the first element has been removed, true is returned; if the end of the collection is reached, false is returned.

Specified by:
remove in interface Collection<E>
Overrides:
remove in class AbstractCollection<E>
Parameters:
o - the object to remove from this collection
Returns:
true if the remove operation caused the Collection to change, or equivalently if the collection did contain o.
See Also:
Iterator.remove()

size

public int size()
Description copied from class: AbstractCollection
Return the number of elements in this collection. If there are more than Integer.MAX_VALUE elements, return Integer.MAX_VALUE.

Specified by:
size in interface Collection<E>
Specified by:
size in class AbstractCollection<E>
Returns:
the size

addAll

public boolean addAll(Collection<? extends E> c)
Description copied from class: AbstractQueue
Adds all of the elements in the specified collection to this queue. Attempts to addAll of a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

This implementation iterates over the specified collection, and adds each element returned by the iterator to this queue, in turn. A runtime exception encountered while trying to add an element (including, in particular, a null element) may result in only some of the elements having been successfully added when the associated exception is thrown.

Specified by:
addAll in interface Collection<E>
Overrides:
addAll in class AbstractQueue<E>
Parameters:
c - collection containing elements to be added to this queue
Returns:
true if this queue changed as a result of the call
See Also:
AbstractQueue.add(Object)

aicas logo Jamaica 3.4 release 8

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.