FileDocCategorySizeDatePackage
AbstractQueue.javaAPI DocAndroid 1.5 API4309Wed May 06 22:41:04 BST 2009java.util

AbstractQueue

public abstract class AbstractQueue extends AbstractCollection implements Queue
AbstractQueue is an abstract class which implements some of the methods in {@link Queue}. The provided implementations of {@code add, remove} and {@code element} are based on {@code offer, poll}, and {@code peek} except that they throw exceptions to indicate some error instead of returning true or false.
param
the type of the element in the collection.
since
Android 1.0

Fields Summary
Constructors Summary
protected AbstractQueue()
Constructor to be used by subclasses.

since
Android 1.0

        super();
    
Methods Summary
public booleanadd(E o)
Adds an element to the queue.

param
o the element to be added to the queue.
return
{@code true} if the operation succeeds, otherwise {@code false}.
throws
IllegalStateException if the element is not allowed to be added to the queue.
since
Android 1.0

        if (null == o) {
            throw new NullPointerException();
        }
        if (offer(o)) {
            return true;
        }
        throw new IllegalStateException();
    
public booleanaddAll(java.util.Collection c)
Adds all the elements of a collection to the queue. If the collection is the queue itself, then an IllegalArgumentException will be thrown. If during the process, some runtime exception is thrown, then those elements in the collection which have already successfully been added will remain in the queue. The result of the method is undefined if the collection is modified during the process of the method.

param
c the collection to be added to the queue.
return
{@code true} if the operation succeeds, otherwise {@code false}.
throws
NullPointerException if the collection or any element of it is null.
throws
IllegalArgumentException If the collection to be added to the queue is the queue itself.
since
Android 1.0

        if (null == c) {
            throw new NullPointerException();
        }
        if (this == c) {
            throw new IllegalArgumentException();
        }
        return super.addAll(c);
    
public voidclear()
Removes all elements of the queue, leaving it empty.

since
Android 1.0

        E o;
        do {
            o = poll();
        } while (null != o);
    
public Eelement()
Returns but does not remove the element at the head of the queue.

return
the element at the head of the queue.
throws
NoSuchElementException if the queue is empty.
since
Android 1.0

        E o = peek();
        if (null == o) {
            throw new NoSuchElementException();
        }
        return o;
    
public Eremove()
Removes the element at the head of the queue and returns it.

return
the element at the head of the queue.
throws
NoSuchElementException if the queue is empty.
since
Android 1.0

        E o = poll();
        if (null == o) {
            throw new NoSuchElementException();
        }
        return o;