Build 1.0_r1(from source)

java.util
Class AbstractQueue<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
Type Parameters:
E - the type of the element in the collection.
All Implemented Interfaces:
Iterable<E>, Collection<E>, Queue<E>
Direct Known Subclasses:
ArrayBlockingQueue, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingQueue, PriorityBlockingQueue, PriorityQueue, SynchronousQueue

public abstract class AbstractQueue<E>
extends AbstractCollection<E>
implements Queue<E>

An abstract class which gives out skeletal implementations for some methods in Queue which include add, remove, and element that are based on offer, poll, and peek except that they throw exception to indicate the occurrence of some error instead of the return value of false or null.


Constructor Summary
protected AbstractQueue()
          Constructor for the sub classes.
 
Method Summary
 boolean add(E o)
          Adds an element to the queue.
 boolean addAll(Collection<? extends E> c)
          Adds all the elements of a collection to the queue.
 void clear()
          Removes all elements of the queue.
 E element()
          Gets but not removes the element in the head of the queue.
 E remove()
          Gets and removes the element in the head of the queue.
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, 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.Queue
offer, peek, poll
 
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

AbstractQueue

protected AbstractQueue()
Constructor for the sub classes.

Method Detail

add

public boolean add(E o)
Adds an element to the queue.

Specified by:
add in interface Collection<E>
Overrides:
add in class AbstractCollection<E>
Parameters:
o - the element added to the queue.
Returns:
true if the operation succeeds.
Throws:
NullPointerException - if the element is null.
IllegalStateException - if the element is not allowed to be added to the queue.

addAll

public boolean addAll(Collection<? extends E> c)
Adds all the elements of a collection to the queue. If the collection is the queue itself, then an IllegalArgumentException will be thrown out. If during the process, some runtime exception is thrown out, then part of the elements in the collection that have successfully added will remain in the queue. The result of the method is undefined if the collection is modified during the process of the method.

Specified by:
addAll in interface Collection<E>
Overrides:
addAll in class AbstractCollection<E>
Parameters:
c - the collection to be added to the queue.
Returns:
true if the operation succeeds.
Throws:
NullPointerException - if the collection or any element of it is null.
IllegalArgumentException - If the collection to be added to the queue is the queue itself.

remove

public E remove()
Gets and removes the element in the head of the queue.

Specified by:
remove in interface Queue<E>
Returns:
the element in the head of the queue.
Throws:
NoSuchElementException - if the queue is empty.

element

public E element()
Gets but not removes the element in the head of the queue.

Specified by:
element in interface Queue<E>
Returns:
the element in the head of the queue.
Throws:
NoSuchElementException - if the queue is empty.

clear

public void clear()
Removes all elements of the queue.

Specified by:
clear in interface Collection<E>
Overrides:
clear in class AbstractCollection<E>
See Also:
Collection.isEmpty(), Collection.size()

Build 1.0_r1(from source)

Please submit a feedback, bug or feature