This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.util
class AbstractQueue

java.lang.Object extended by java.util.AbstractCollection extended by java.util.AbstractQueue
All Implemented Interfaces:
Collection, Queue
Direct Known Subclasses:
ArrayBlockingQueue, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingDeque, LinkedBlockingQueue, PriorityBlockingQueue, PriorityQueue, SynchronousQueue

public abstract class AbstractQueue
extends AbstractCollection
implements Queue

This class provides skeletal implementations of some {@link Queue} operations. The implementations in this class are appropriate when the base implementation does not allow null elements. Methods {@link #add add}, {@link #remove remove}, and {@link #element element} are based on {@link #offer offer}, {@link #poll poll}, and {@link #peek peek}, respectively but throw exceptions instead of indicating failure via false or null returns.

A Queue implementation that extends this class must minimally define a method {@link Queue#offer} which does not permit insertion of null elements, along with methods {@link Queue#peek}, {@link Queue#poll}, {@link Collection#size}, and a {@link Collection#iterator} supporting {@link Iterator#remove}. Typically, additional methods will be overridden as well. If these requirements cannot be met, consider instead subclassing {@link AbstractCollection}.

This class is a member of the Java Collections Framework.


Constructor Summary
protected

          Constructor for use by subclasses.
 
Method Summary
 boolean

          Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
 boolean

          Adds all of the elements in the specified collection to this queue.
 void

          Removes all of the elements from this queue.
 Object

          Retrieves, but does not remove, the head of this queue.
 Object

          Retrieves and removes the head of this queue.
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, 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, toString, wait, wait, wait
 

Constructor Detail

AbstractQueue

protected AbstractQueue()
Constructor for use by subclasses.

Method Detail

add

public boolean add(Object e)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.

This implementation returns true if offer succeeds, else throws an IllegalStateException.

Overrides:
add in class AbstractCollection
Parameters:
e - the element to add
Returns:
true (as specified by {@link Collection#add})

addAll

public boolean addAll(Collection c)
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.

Overrides:
addAll in class AbstractCollection
Parameters:
c - collection containing elements to be added to this queue
Returns:
true if this queue changed as a result of the call

clear

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

This implementation repeatedly invokes {@link #poll poll} until it returns null.

Overrides:
clear in class AbstractCollection

element

public Object element()
Retrieves, but does not remove, the head of this queue. This method differs from {@link #peek peek} only in that it throws an exception if this queue is empty.

This implementation returns the result of peek unless the queue is empty.

Returns:
the head of this queue

remove

public Object remove()
Retrieves and removes the head of this queue. This method differs from {@link #poll poll} only in that it throws an exception if this queue is empty.

This implementation returns the result of poll unless the queue is empty.

Returns:
the head of this queue


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.