# AbstractQueue

public abstract class **AbstractQueue** extends [AbstractCollection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html)\<E\>  
implements [Queue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html)\<E\>

|---|---|---|
| Known Direct Subclasses [ArrayBlockingQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ArrayBlockingQueue.html)\<E\>, [ConcurrentLinkedQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ConcurrentLinkedQueue.html)\<E\>, [DelayQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/DelayQueue.html)\<E extends [Delayed](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Delayed.html)\>, [LinkedBlockingDeque](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/LinkedBlockingDeque.html)\<E\>, [LinkedBlockingQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/LinkedBlockingQueue.html)\<E\>, [LinkedTransferQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/LinkedTransferQueue.html)\<E\>, [PriorityBlockingQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/PriorityBlockingQueue.html)\<E\>, [PriorityQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PriorityQueue.html)\<E\>, [SynchronousQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/SynchronousQueue.html)\<E\> |---|---| | [ArrayBlockingQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ArrayBlockingQueue.html)\<E\> | A bounded {@linkplain BlockingQueue blocking queue} backed by an array. | | [ConcurrentLinkedQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ConcurrentLinkedQueue.html)\<E\> | An unbounded thread-safe {@linkplain Queue queue} based on linked nodes. | | [DelayQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/DelayQueue.html)\<E extends [Delayed](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Delayed.html)\> | An unbounded {@linkplain BlockingQueue blocking queue} of `Delayed` elements, in which an element can only be taken when its delay has expired. | | [LinkedBlockingDeque](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/LinkedBlockingDeque.html)\<E\> | An optionally-bounded {@linkplain BlockingDeque blocking deque} based on linked nodes. | | [LinkedBlockingQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/LinkedBlockingQueue.html)\<E\> | An optionally-bounded {@linkplain BlockingQueue blocking queue} based on linked nodes. | | [LinkedTransferQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/LinkedTransferQueue.html)\<E\> | An unbounded `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TransferQueue.html` based on linked nodes. | | [PriorityBlockingQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/PriorityBlockingQueue.html)\<E\> | An unbounded {@linkplain BlockingQueue blocking queue} that uses the same ordering rules as class `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PriorityQueue.html` and supplies blocking retrieval operations. | | [PriorityQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/PriorityQueue.html)\<E\> | An unbounded priority {@linkplain Queue queue} based on a priority heap. | | [SynchronousQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/SynchronousQueue.html)\<E\> | A {@linkplain BlockingQueue blocking queue} in which each insert operation must wait for a corresponding remove operation by another thread, and vice versa. | |||

This class provides skeletal implementations of some `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html`
operations. The implementations in this class are appropriate when
the base implementation does *not* allow `null`
elements. Methods `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#add(E)`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#remove()`, and
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#element()` are based on `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#offer(E)`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#poll()`, and `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#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 `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#offer(E)` which does not permit
insertion of `null` elements, along with methods `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#peek()`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#poll()`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#size()`, and
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#iterator()`. Typically, additional methods will be
overridden as well. If these requirements cannot be met, consider
instead subclassing `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html`.

### Protected Constructor Summary

|---|---|
|   | [AbstractQueue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#AbstractQueue())() Constructor for use by subclasses. |

### Public Method Summary

|---|---|
| boolean | [add](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#add(E))(E 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. |
| boolean | [addAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#addAll(java.util.Collection<?%20extends%20E>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends E\> c) Adds all of the elements in the specified collection to this queue. |
| void | [clear](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#clear())() Removes all of the elements from this queue. |
| E | [element](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#element())() Retrieves, but does not remove, the head of this queue. |
| E | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#remove())() Retrieves and removes the head of this queue. |

### Inherited Method Summary

From class [java.util.AbstractCollection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html)

|---|---|
| boolean | [add](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#add(E))(E e) Ensures that this collection contains the specified element (optional operation). This implementation always throws an UnsupportedOperationException. |
| boolean | [addAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#addAll(java.util.Collection<?%20extends%20E>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends E\> c) Adds all of the elements in the specified collection to this collection (optional operation). This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn. |
| void | [clear](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#clear())() Removes all of the elements from this collection (optional operation). This implementation iterates over this collection, removing each element using the Iterator.remove operation. |
| boolean | [contains](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#contains(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Returns true if this collection contains the specified element. This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element. |
| boolean | [containsAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#containsAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Returns true if this collection contains all of the elements in the specified collection. This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. |
| boolean | [isEmpty](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#isEmpty())() Returns true if this collection contains no elements. This implementation returns size() == 0. |
| abstract [Iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html)\<E\> | [iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#iterator())() Returns an iterator over the elements contained in this collection. |
| boolean | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#remove(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Removes a single instance of the specified element from this collection, if it is present (optional operation). This implementation iterates over the collection looking for the specified element. |
| boolean | [removeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#removeAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Removes all of this collection's elements that are also contained in the specified collection (optional operation). This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. |
| boolean | [retainAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#retainAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Retains only the elements in this collection that are contained in the specified collection (optional operation). This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. |
| abstract int | [size](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#size())() Returns the number of elements in this collection. |
| \<T\> T\[\] | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#toArray(T[]))(T\[\] contents) Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. This implementation returns an array containing all the elements returned by this collection's iterator in the same order, stored in consecutive elements of the array, starting with index `0`. |
| [Object\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#toArray())() Returns an array containing all of the elements in this collection. This implementation returns an array containing all the elements returned by this collection's iterator, in the same order, stored in consecutive elements of the array, starting with index `0`. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractCollection.html#toString())() Returns a string representation of this collection. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.util.Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)

|---|---|
| abstract boolean | [add](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#add(E))(E e) Ensures that this collection contains the specified element (optional operation). |
| abstract boolean | [addAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#addAll(java.util.Collection<?%20extends%20E>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends E\> c) Adds all of the elements in the specified collection to this collection (optional operation). |
| abstract void | [clear](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#clear())() Removes all of the elements from this collection (optional operation). |
| abstract boolean | [contains](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#contains(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Returns true if this collection contains the specified element. |
| abstract boolean | [containsAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#containsAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Returns true if this collection contains all of the elements in the specified collection. |
| abstract boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Compares the specified object with this collection for equality. |
| abstract int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#hashCode())() Returns the hash code value for this collection. |
| abstract boolean | [isEmpty](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#isEmpty())() Returns true if this collection contains no elements. |
| abstract [Iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html)\<E\> | [iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#iterator())() Returns an iterator over the elements in this collection. |
| [Stream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/stream/Stream.html)\<E\> | [parallelStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#parallelStream())() Returns a possibly parallel `Stream` with this collection as its source. |
| abstract boolean | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#remove(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Removes a single instance of the specified element from this collection, if it is present (optional operation). |
| abstract boolean | [removeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#removeAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Removes all of this collection's elements that are also contained in the specified collection (optional operation). |
| boolean | [removeIf](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#removeIf(java.util.function.Predicate<?%20super%20E>))([Predicate](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Predicate.html)\<? super E\> filter) Removes all of the elements of this collection that satisfy the given predicate. |
| abstract boolean | [retainAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#retainAll(java.util.Collection<?>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<?\> c) Retains only the elements in this collection that are contained in the specified collection (optional operation). |
| abstract int | [size](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#size())() Returns the number of elements in this collection. |
| [Spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Spliterator.html)\<E\> | [spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#spliterator())() Creates a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Spliterator.html` over the elements in this collection. |
| [Stream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/stream/Stream.html)\<E\> | [stream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#stream())() Returns a sequential `Stream` with this collection as its source. |
| abstract \<T\> T\[\] | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#toArray(T[]))(T\[\] a) Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. |
| abstract [Object\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [toArray](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#toArray())() Returns an array containing all of the elements in this collection. |

From interface [java.util.Queue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html)

|---|---|
| abstract boolean | [add](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#add(E))(E 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. |
| abstract E | [element](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#element())() Retrieves, but does not remove, the head of this queue. |
| abstract boolean | [offer](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#offer(E))(E e) Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. |
| abstract E | [peek](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#peek())() Retrieves, but does not remove, the head of this queue, or returns `null` if this queue is empty. |
| abstract E | [poll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#poll())() Retrieves and removes the head of this queue, or returns `null` if this queue is empty. |
| abstract E | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#remove())() Retrieves and removes the head of this queue. |

From interface [java.lang.Iterable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Iterable.html)

|---|---|
| void | [forEach](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Iterable.html#forEach(java.util.function.Consumer<?%20super%20T>))([Consumer](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Consumer.html)\<? super T\> action) Performs the given action for each element of the `Iterable` until all elements have been processed or the action throws an exception. |
| abstract [Iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Iterator.html)\<E\> | [iterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Iterable.html#iterator())() Returns an iterator over elements of type `T`. |
| [Spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Spliterator.html)\<E\> | [spliterator](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Iterable.html#spliterator())() Creates a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Spliterator.html` over the elements described by this `Iterable`. |

## Protected Constructors

#### protected
**AbstractQueue**
()

Constructor for use by subclasses.

## Public Methods

#### public boolean
**add**
(E 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`.

##### Parameters

| e | the element to add |
|---|---|

##### Returns

- `true` (as specified by `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html#add(E)`)

##### Throws

| [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html) | if the element cannot be added at this time due to capacity restrictions |
| [ClassCastException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ClassCastException.html) | if the class of the specified element prevents it from being added to this queue |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the specified element is null and this queue does not permit null elements |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if some property of this element prevents it from being added to this queue |
|---|---|

#### public boolean
**addAll**
([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends E\> 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.

##### Parameters

| c | collection containing elements to be added to this queue |
|---|---|

##### Returns

- `true` if this queue changed as a result of the call

##### Throws

| [ClassCastException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ClassCastException.html) | if the class of an element of the specified collection prevents it from being added to this queue |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the specified collection contains a null element and this queue does not permit null elements, or if the specified collection is null |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if 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 |
| [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html) | if not all the elements can be added at this time due to insertion restrictions |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractQueue.html#add(E)`

#### public void
**clear**
()

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

This implementation repeatedly invokes `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#poll()` until it
returns `null`.

#### public E
**element**
()

Retrieves, but does not remove, the head of this queue. This method
differs from `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#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

##### Throws

| [NoSuchElementException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/NoSuchElementException.html) | if this queue is empty |
|---|---|

#### public E
**remove**
()

Retrieves and removes the head of this queue. This method differs
from `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Queue.html#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

##### Throws

| [NoSuchElementException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/NoSuchElementException.html) | if this queue is empty |
|---|---|