| 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 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
ArrayDeque()
Constructs a new empty instance of ArrayDeque big enough for 16 elements.
| |||||||||||
|
ArrayDeque(int minSize)
Constructs a new empty instance of ArrayDeque big enough for specified number
of elements.
| |||||||||||
|
ArrayDeque(Collection<? extends E> c)
Constructs a new instance of ArrayDeque containing the elements of the
specified collection, with the order returned by the collection's iterator.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| boolean |
add(Object e)
Inserts the element to the tail of the deque.
| ||||||||||
| void | addFirst(Object e) | ||||||||||
| void | addLast(Object e) | ||||||||||
| void |
clear()
Empty the deque.
| ||||||||||
| boolean |
contains(Object obj)
Returns true if the specified element is in the deque.
| ||||||||||
| Iterator<E> |
descendingIterator()
Returns the iterator in reverse order, from tail to head.
| ||||||||||
| E |
element()
Gets but does not remove the head element of this deque.
| ||||||||||
| E |
getFirst()
Gets but not removes the head element of this deque.
| ||||||||||
| E |
getLast()
Gets but not removes the tail element of this deque.
| ||||||||||
| boolean |
isEmpty()
Returns true if the deque has no elements.
| ||||||||||
| Iterator<E> |
iterator()
Returns the iterator of the deque.
| ||||||||||
| boolean |
offer(Object e)
Inserts the element at the tail of the deque.
| ||||||||||
| boolean | offerFirst(Object e) | ||||||||||
| boolean | offerLast(Object e) | ||||||||||
| E |
peek()
Gets but not removes the head element of this deque.
| ||||||||||
| E |
peekFirst()
Gets but not removes the head element of this deque.
| ||||||||||
| E |
peekLast()
Gets but not removes the tail element of this deque.
| ||||||||||
| E |
poll()
Gets and removes the head element of this deque.
| ||||||||||
| E |
pollFirst()
Gets and removes the head element of this deque.
| ||||||||||
| E |
pollLast()
Gets and removes the tail element of this deque.
| ||||||||||
| E |
pop()
Pops the head element of the deque, just same as removeFirst().
| ||||||||||
| void | push(Object e) | ||||||||||
| E |
remove()
Gets and removes the head element of this deque.
| ||||||||||
| boolean |
remove(Object obj)
Removes the first equivalent element of the specified object.
| ||||||||||
| E |
removeFirst()
Gets and removes the head element of this deque.
| ||||||||||
| boolean |
removeFirstOccurrence(Object obj)
Removes the first equivalent element of the specified object.
| ||||||||||
| E |
removeLast()
Gets and removes the tail element of this deque.
| ||||||||||
| boolean |
removeLastOccurrence(Object obj)
Removes the last equivalent element of the specified object.
| ||||||||||
| int |
size()
Returns the size of the deque.
| ||||||||||
|
[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 |
|---|
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 |
|---|
| 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 |
|---|
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 |
|---|