E - the type of elements in this collectionpublic class ArrayDeque<E> extends AbstractCollection<E> implements Deque<E>
| Constructor and Description |
|---|
ArrayDeque()
Constructs a new empty instance of ArrayDeque big enough for 16 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.
|
ArrayDeque(int minSize)
Constructs a new empty instance of ArrayDeque big enough for specified
number of elements.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e)
Inserts the element to the tail of the deque.
|
void |
addFirst(E e)
Inserts an element at the head of this deque if it dose not violate size
limit immediately.
|
void |
addLast(E e)
Inserts an element at the tail of this deque if it dose not violate size
limit immediately.
|
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(E e)
Inserts the element at the tail of the deque.
|
boolean |
offerFirst(E e)
Inserts an element at the head of this deque unless it would violate size
limit.
|
boolean |
offerLast(E e)
Inserts an element at the tail of this deque unless it would violate size
limit.
|
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(E e)
Pushes the element to the deque(at the head of the deque), just same as
addFirst(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.
|
addAll, containsAll, removeAll, retainAll, toArray, toArray, toStringclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitaddAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArraypublic ArrayDeque()
public ArrayDeque(int minSize)
minSize - the smallest size of the ArrayDequepublic ArrayDeque(Collection<? extends E> c)
c - the source of the elementsNullPointerException - if the collection is nullpublic void addFirst(E e)
addFirst in interface Deque<E>e - the elementNullPointerException - if the element is nullDeque.addFirst(java.lang.Object)public void addLast(E e)
addLast in interface Deque<E>e - the elementNullPointerException - if the element is nullDeque.addLast(java.lang.Object)public boolean offerFirst(E e)
offerFirst in interface Deque<E>e - the elementNullPointerException - if the element is nullDeque.offerFirst(java.lang.Object)public boolean offerLast(E e)
offerLast in interface Deque<E>e - the elementNullPointerException - if the element is nullDeque.offerLast(java.lang.Object)public boolean offer(E e)
offer in interface Queue<E>e - the elementNullPointerException - if the element is nullQueue.offer(java.lang.Object)public boolean add(E e)
add in interface Collection<E>add in class AbstractCollection<E>e - the elementAbstractCollection.add(java.lang.Object)public void push(E e)
push in interface Deque<E>e - the element to pushNullPointerException - if the element is nullDeque.push(java.lang.Object)public E removeFirst()
removeFirst in interface Deque<E>NoSuchElementException - if the deque is emptyDeque.removeFirst()public E remove()
remove in interface Queue<E>NoSuchElementException - if the deque is emptyQueue.remove()public E pop()
pop in interface Deque<E>NoSuchElementException - if the deque is emptyDeque.pop()public E removeLast()
removeLast in interface Deque<E>NoSuchElementException - if the deque is emptyDeque.removeLast()public E pollFirst()
pollFirst in interface Deque<E>Deque.pollFirst()public E poll()
poll in interface Queue<E>Queue.poll()public E pollLast()
pollLast in interface Deque<E>Deque.pollLast()public E getFirst()
getFirst in interface Deque<E>NoSuchElementException - if the deque is emptyDeque.getFirst()public E element()
element in interface Queue<E>NoSuchElementException - if the deque is emptyQueue.element()public E getLast()
getLast in interface Deque<E>NoSuchElementException - if the deque is emptyDeque.getLast()public E peekFirst()
peekFirst in interface Deque<E>Deque.peekFirst()public E peek()
peek in interface Queue<E>Queue.peek()public E peekLast()
peekLast in interface Deque<E>Deque.peekLast()public boolean removeFirstOccurrence(Object obj)
removeFirstOccurrence in interface Deque<E>obj - the element to be removedDeque.removeFirstOccurrence(java.lang.Object)public boolean remove(Object obj)
remove in interface Collection<E>remove in class AbstractCollection<E>obj - the element to be removedAbstractCollection.remove(java.lang.Object)public boolean removeLastOccurrence(Object obj)
removeLastOccurrence in interface Deque<E>obj - the element to be removedDeque.removeLastOccurrence(java.lang.Object)public int size()
size in interface Collection<E>size in class AbstractCollection<E>AbstractCollection.size()public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in class AbstractCollection<E>AbstractCollection.isEmpty()public boolean contains(Object obj)
contains in interface Collection<E>contains in class AbstractCollection<E>obj - the elementAbstractCollection.contains(java.lang.Object)public void clear()
clear in interface Collection<E>clear in class AbstractCollection<E>AbstractCollection.clear()public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class AbstractCollection<E>AbstractCollection.iterator()public Iterator<E> descendingIterator()
descendingIterator in interface Deque<E>Deque.descendingIterator()