DthingApi
Public Member Functions | Protected Member Functions | List of all members
java.util.AbstractQueue< E > Class Template Referenceabstract
Inheritance diagram for java.util.AbstractQueue< E >:
java.util.AbstractCollection< E > java.util.Queue< E > java.util.Collection< E > java.util.Collection< E >

Public Member Functions

boolean add (E e)
 
remove ()
 
element ()
 
void clear ()
 
boolean addAll (Collection<? extends E > c)
 
- Public Member Functions inherited from java.util.AbstractCollection< E >
boolean add (E object)
 
boolean addAll (Collection<? extends E > collection)
 
void clear ()
 
boolean contains (Object object)
 
boolean containsAll (Collection<?> collection)
 
boolean isEmpty ()
 
abstract Iterator< E > iterator ()
 
boolean remove (Object object)
 
boolean removeAll (Collection<?> collection)
 
boolean retainAll (Collection<?> collection)
 
abstract int size ()
 
Object [] toArray ()
 
String toString ()
 
- Public Member Functions inherited from java.util.Collection< E >
boolean equals (Object object)
 
int hashCode ()
 
- Public Member Functions inherited from java.util.Queue< E >
boolean offer (E e)
 
poll ()
 
peek ()
 

Protected Member Functions

 AbstractQueue ()
 
- Protected Member Functions inherited from java.util.AbstractCollection< E >
 AbstractCollection ()
 

Detailed Description

This class provides skeletal implementations of some Queue operations. The implementations in this class are appropriate when the base implementation does not allow null elements. Methods add, remove, and element are based on offer, poll, and 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 Queue#offer which does not permit insertion of null elements, along with methods Queue#peek, Queue#poll, Collection#size, and Collection#iterator. Typically, additional methods will be overridden as well. If these requirements cannot be met, consider instead subclassing AbstractCollection.

Since
1.5
Author
Doug Lea
Parameters
<E>the type of elements held in this collection

Constructor & Destructor Documentation

◆ AbstractQueue()

java.util.AbstractQueue< E >.AbstractQueue ( )
inlineprotected

Constructor for use by subclasses.

Member Function Documentation

◆ add()

boolean java.util.AbstractQueue< E >.add ( e)
inline

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.

Parameters
ethe element to add
Returns
true (as specified by Collection#add)
Exceptions
IllegalStateExceptionif the element cannot be added at this time due to capacity restrictions
ClassCastExceptionif the class of the specified element prevents it from being added to this queue
NullPointerExceptionif the specified element is null and this queue does not permit null elements
IllegalArgumentExceptionif some property of this element prevents it from being added to this queue

Implements java.util.Queue< E >.

◆ addAll()

boolean java.util.AbstractQueue< E >.addAll ( Collection<? extends E >  c)
inline

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.

Parameters
ccollection containing elements to be added to this queue
Returns
true if this queue changed as a result of the call
Exceptions
ClassCastExceptionif the class of an element of the specified collection prevents it from being added to this queue
NullPointerExceptionif the specified collection contains a null element and this queue does not permit null elements, or if the specified collection is null
IllegalArgumentExceptionif some property of an element of the specified collection prevents it from being added to this queue, or if the specified collection is this queue
IllegalStateExceptionif not all the elements can be added at this time due to insertion restrictions
See also
#add(Object)

Implements java.util.Collection< E >.

◆ clear()

void java.util.AbstractQueue< E >.clear ( )
inline

Removes all of the elements from this queue. The queue will be empty after this call returns.

This implementation repeatedly invokes poll until it returns null.

Implements java.util.Collection< E >.

◆ element()

E java.util.AbstractQueue< E >.element ( )
inline

Retrieves, but does not remove, the head of this queue. This method differs from 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
Exceptions
NoSuchElementExceptionif this queue is empty

Implements java.util.Queue< E >.

◆ remove()

E java.util.AbstractQueue< E >.remove ( )
inline

Retrieves and removes the head of this queue. This method differs from 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
Exceptions
NoSuchElementExceptionif this queue is empty

Implements java.util.Queue< E >.


The documentation for this class was generated from the following file: