Final

java.util
Class AbstractQueue<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
Type Parameters:
E - the types of objects this queue can hold
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>

Abstract superclass for Queue implementations.

Since:
1.5

Constructor Summary
protected AbstractQueue()
          Default constructor.
 
Method Summary
 boolean add(E object)
          Adds the given object to the queue.
 boolean addAll(Collection<? extends E> collection)
          Adds the objects from the given collection to the queue.
 void clear()
          Removes all objects from this queue.
 E element()
          Returns the head object of the queue.
 E remove()
          Removes the head object from 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()
Default constructor.

Method Detail

add

public boolean add(E object)
Adds the given object to the queue.

Specified by:
add in interface Collection<E>
Overrides:
add in class AbstractCollection<E>
Parameters:
object - the object to add
Returns:
true
Throws:
NullPointerException - if the object is null
IllegalStateException - if the object cannot be added

addAll

public boolean addAll(Collection<? extends E> collection)
Adds the objects from the given collection to the queue.

Specified by:
addAll in interface Collection<E>
Overrides:
addAll in class AbstractCollection<E>
Parameters:
collection - the Collection of objects
Returns:
true if the queue changed
Throws:
NullPointerException - if the collection or any of it's objects are null
IllegalArgumentException - if the collection is this queue

clear

public void clear()
Removes all objects from this queue.

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

element

public E element()
Returns the head object of the queue. Does not remove the object from the queue.

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

remove

public E remove()
Removes the head object from the queue.

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

Final

Licensed Materials - Property of IBM
© Copyright IBM Corp. 2006, 2008 All Rights Reserved.