java.lang.Object | ||
↳ | java.util.AbstractCollection<E> | |
↳ | java.util.ArrayDeque<E> |
An implementation of Deque, backed by an array. ArrayDeques have no size limit, can not contain null element, and they are not thread-safe. All optional operations are supported, and the elements can be any objects.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new empty instance of ArrayDeque big enough for 16 elements.
| |||||||||||
Constructs a new empty instance of ArrayDeque big enough for specified
number of elements.
| |||||||||||
Constructs a new instance of ArrayDeque containing the elements of the
specified collection, with the order returned by the collection's
iterator.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Inserts the element to the tail of the deque.
| |||||||||||
Inserts an element at the head of this deque if it dose not violate size
limit immediately.
| |||||||||||
Inserts an element at the tail of this deque if it dose not violate size
limit immediately.
| |||||||||||
Empty the deque.
| |||||||||||
Returns a clone of the deque.
| |||||||||||
Returns true if the specified element is in the deque.
| |||||||||||
Returns the iterator in reverse order, from tail to head.
| |||||||||||
Gets but does not remove the head element of this deque.
| |||||||||||
Gets but not removes the head element of this deque.
| |||||||||||
Gets but not removes the tail element of this deque.
| |||||||||||
Returns true if the deque has no elements.
| |||||||||||
Returns the iterator of the deque.
| |||||||||||
Inserts the element at the tail of the deque.
| |||||||||||
Inserts an element at the head of this deque unless it would violate size
limit.
| |||||||||||
Inserts an element at the tail of this deque unless it would violate size
limit.
| |||||||||||
Gets but not removes the head element of this deque.
| |||||||||||
Gets but not removes the head element of this deque.
| |||||||||||
Gets but not removes the tail element of this deque.
| |||||||||||
Gets and removes the head element of this deque.
| |||||||||||
Gets and removes the head element of this deque.
| |||||||||||
Gets and removes the tail element of this deque.
| |||||||||||
Pops the head element of the deque, just same as removeFirst().
| |||||||||||
Pushes the element to the deque(at the head of the deque), just same as
addFirst(E).
| |||||||||||
Gets and removes the head element of this deque.
| |||||||||||
Removes the first equivalent element of the specified object.
| |||||||||||
Gets and removes the head element of this deque.
| |||||||||||
Removes the first equivalent element of the specified object.
| |||||||||||
Gets and removes the tail element of this deque.
| |||||||||||
Removes the last equivalent element of the specified object.
| |||||||||||
Returns the size of the deque.
| |||||||||||
Returns all the elements in an array from head to tail, and the type of
the result array is the type of the argument array.
| |||||||||||
Returns all the elements in an array from head to tail.
|
[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.Deque
| |||||||||||
From interface java.util.Queue
|
Constructs a new empty instance of ArrayDeque big enough for 16 elements.
Constructs a new empty instance of ArrayDeque big enough for specified number of elements.
minSize | the smallest size of the ArrayDeque |
---|
Constructs a new instance of ArrayDeque containing the elements of the specified collection, with the order returned by the collection's iterator.
c | the source of the elements |
---|
NullPointerException | if the collection is null |
---|
Inserts the element to the tail of the deque.
e | the element |
---|
Inserts an element at the head of this deque if it dose not violate size limit immediately. It is better to use offerFirst(E) if a deque is size-limited.
e | the element |
---|
NullPointerException | if the element is null |
---|
Inserts an element at the tail of this deque if it dose not violate size limit immediately. It is better to use offerLast(E) if a deque is size-limited.
e | the element |
---|
NullPointerException | if the element is null |
---|
Returns true if the specified element is in the deque.
obj | the element |
---|
Returns the iterator in reverse order, from tail to head.
Gets but does not remove the head element of this deque. It throws an exception if the deque is empty.
NoSuchElementException | if the deque is empty |
---|
Gets but not removes the head element of this deque. This method throws an exception if the deque is empty.
NoSuchElementException | if the deque is empty |
---|
Gets but not removes the tail element of this deque. This method throws an exception if the deque is empty.
NoSuchElementException | if the deque is empty |
---|
Returns true if the deque has no elements.
Returns the iterator of the deque. The elements will be ordered from head to tail.
Inserts the element at the tail of the deque.
e | the element |
---|
NullPointerException | if the element is null |
---|
Inserts an element at the head of this deque unless it would violate size limit. It is better than the addFirst(E) method in a size-limited deque, because the latter one may fail to add the element only by throwing an exception.
e | the element |
---|
NullPointerException | if the element is null |
---|
Inserts an element at the tail of this deque unless it would violate size limit. It is better than the addLast(E) method in a size-limited deque, because the latter one may fail to add the element only by throwing an exception.
e | the element |
---|
NullPointerException | if the element is null |
---|
Gets but not removes the head element of this deque. This method returns null if the deque is empty.
Gets but not removes the head element of this deque. This method returns null if the deque is empty.
Gets but not removes the tail element of this deque. This method returns null if the deque is empty.
Gets and removes the head element of this deque. This method returns null if the deque is empty.
Gets and removes the head element of this deque. This method returns null if the deque is empty.
Gets and removes the tail element of this deque. This method returns null if the deque is empty.
Pops the head element of the deque, just same as removeFirst().
NoSuchElementException | if the deque is empty |
---|
Pushes the element to the deque(at the head of the deque), just same as addFirst(E).
e | the element to push |
---|
NullPointerException | if the element is null |
---|
Gets and removes the head element of this deque. This method throws an exception if the deque is empty.
NoSuchElementException | if the deque is empty |
---|
Removes the first equivalent element of the specified object. If the deque does not contain the element, it is unchanged and returns false.
obj | the element to be removed |
---|
Gets and removes the head element of this deque. This method throws an exception if the deque is empty.
NoSuchElementException | if the deque is empty |
---|
Removes the first equivalent element of the specified object. If the deque does not contain the element, it is unchanged and returns false.
obj | the element to be removed |
---|
Gets and removes the tail element of this deque. This method throws an exception if the deque is empty.
NoSuchElementException | if the deque is empty |
---|
Removes the last equivalent element of the specified object. If the deque does not contain the element, it is unchanged and returns false.
obj | the element to be removed |
---|
Returns all the elements in an array from head to tail, and the type of the result array is the type of the argument array. If the argument array is big enough, the elements from the deque will be stored in it(elements following the tail of the deque is set to null, if any); otherwise, it will return a new array with the size of the argument array and size of the deque.
array | the array stores all the elements from the deque, if it has enough space; otherwise, a new array of the same type and the size of the deque will be used |
---|
ArrayStoreException | if the type of the argument array is not compatible with every element in the deque |
---|---|
NullPointerException | if the argument array is null |
Returns all the elements in an array from head to tail. The result is a copy of all the elements.