加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090218032429/http://developer.android.com:80/reference/java/util/AbstractQueue.html
public abstract class

AbstractQueue

extends AbstractCollection<E>
implements Queue<E>
java.lang.Object
   ↳ java.util.AbstractCollection<E>
     ↳ java.util.AbstractQueue<E>
Known Direct Subclasses

Class Overview

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.

Summary

Protected Constructors
AbstractQueue()
Constructor for the sub classes.
Public Methods
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.
[Expand]
Inherited Methods
From class java.util.AbstractCollection
From class java.lang.Object
From interface java.lang.Iterable
From interface java.util.Collection
From interface java.util.Queue

Protected Constructors

protected AbstractQueue ()

Constructor for the sub classes.

Public Methods

public boolean add (E o)

Adds an element to the queue.

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.

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.

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.

public void clear ()

Removes all elements of the queue.

public E element ()

Gets but not removes the element in the head of the queue.

Returns
  • the element in the head of the queue.
Throws
NoSuchElementException if the queue is empty.

public E remove ()

Gets and removes the element in the head of the queue.

Returns
  • the element in the head of the queue.
Throws
NoSuchElementException if the queue is empty.