Methods Summary |
---|
public boolean | add(E e)Inserts the specified element into the queue represented by this deque
(in other words, at the tail of this deque) 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.
When using a capacity-restricted deque, it is generally preferable to
use {@link #offer(Object) offer}.
This method is equivalent to {@link #addLast}.
|
public void | addFirst(E e)Inserts the specified element at the front of this deque if it is
possible to do so immediately without violating capacity restrictions.
When using a capacity-restricted deque, it is generally preferable to
use method {@link #offerFirst}.
|
public void | addLast(E e)Inserts the specified element at the end of this deque if it is
possible to do so immediately without violating capacity restrictions.
When using a capacity-restricted deque, it is generally preferable to
use method {@link #offerLast}.
This method is equivalent to {@link #add}.
|
public boolean | contains(java.lang.Object o)Returns true if this deque contains the specified element.
More formally, returns true if and only if this deque contains
at least one element e such that
(o==null ? e==null : o.equals(e)).
|
public java.util.Iterator | descendingIterator()Returns an iterator over the elements in this deque in reverse
sequential order. The elements will be returned in order from
last (tail) to first (head).
|
public E | element()Retrieves, but does not remove, the head of the queue represented by
this deque (in other words, the first element of this deque).
This method differs from {@link #peek peek} only in that it throws an
exception if this deque is empty.
This method is equivalent to {@link #getFirst()}.
|
public E | getFirst()Retrieves, but does not remove, the first element of this deque.
This method differs from {@link #peekFirst peekFirst} only in that it
throws an exception if this deque is empty.
|
public E | getLast()Retrieves, but does not remove, the last element of this deque.
This method differs from {@link #peekLast peekLast} only in that it
throws an exception if this deque is empty.
|
public java.util.Iterator | iterator()Returns an iterator over the elements in this deque in proper sequence.
The elements will be returned in order from first (head) to last (tail).
|
public boolean | offer(E e)Inserts the specified element into the queue represented by this deque
(in other words, at the tail of this deque) if it is possible to do so
immediately without violating capacity restrictions, returning
true upon success and false if no space is currently
available. When using a capacity-restricted deque, this method is
generally preferable to the {@link #add} method, which can fail to
insert an element only by throwing an exception.
This method is equivalent to {@link #offerLast}.
|
public boolean | offerFirst(E e)Inserts the specified element at the front of this deque unless it would
violate capacity restrictions. When using a capacity-restricted deque,
this method is generally preferable to the {@link #addFirst} method,
which can fail to insert an element only by throwing an exception.
|
public boolean | offerLast(E e)Inserts the specified element at the end of this deque unless it would
violate capacity restrictions. When using a capacity-restricted deque,
this method is generally preferable to the {@link #addLast} method,
which can fail to insert an element only by throwing an exception.
|
public E | peek()Retrieves, but does not remove, the head of the queue represented by
this deque (in other words, the first element of this deque), or
returns null if this deque is empty.
This method is equivalent to {@link #peekFirst()}.
|
public E | peekFirst()Retrieves, but does not remove, the first element of this deque,
or returns null if this deque is empty.
|
public E | peekLast()Retrieves, but does not remove, the last element of this deque,
or returns null if this deque is empty.
|
public E | poll()Retrieves and removes the head of the queue represented by this deque
(in other words, the first element of this deque), or returns
null if this deque is empty.
This method is equivalent to {@link #pollFirst()}.
|
public E | pollFirst()Retrieves and removes the first element of this deque,
or returns null if this deque is empty.
|
public E | pollLast()Retrieves and removes the last element of this deque,
or returns null if this deque is empty.
|
public E | pop()Pops an element from the stack represented by this deque. In other
words, removes and returns the first element of this deque.
This method is equivalent to {@link #removeFirst()}.
|
public void | push(E e)Pushes an element onto the stack represented by this deque (in other
words, at the head of this deque) 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 method is equivalent to {@link #addFirst}.
|
public E | remove()Retrieves and removes the head of the queue represented by this deque
(in other words, the first element of this deque).
This method differs from {@link #poll poll} only in that it throws an
exception if this deque is empty.
This method is equivalent to {@link #removeFirst()}.
|
public boolean | remove(java.lang.Object o)Removes the first occurrence of the specified element from this deque.
If the deque does not contain the element, it is unchanged.
More formally, removes the first element e such that
(o==null ? e==null : o.equals(e))
(if such an element exists).
Returns true if this deque contained the specified element
(or equivalently, if this deque changed as a result of the call).
This method is equivalent to {@link #removeFirstOccurrence}.
|
public E | removeFirst()Retrieves and removes the first element of this deque. This method
differs from {@link #pollFirst pollFirst} only in that it throws an
exception if this deque is empty.
|
public boolean | removeFirstOccurrence(java.lang.Object o)Removes the first occurrence of the specified element from this deque.
If the deque does not contain the element, it is unchanged.
More formally, removes the first element e such that
(o==null ? e==null : o.equals(e))
(if such an element exists).
Returns true if this deque contained the specified element
(or equivalently, if this deque changed as a result of the call).
|
public E | removeLast()Retrieves and removes the last element of this deque. This method
differs from {@link #pollLast pollLast} only in that it throws an
exception if this deque is empty.
|
public boolean | removeLastOccurrence(java.lang.Object o)Removes the last occurrence of the specified element from this deque.
If the deque does not contain the element, it is unchanged.
More formally, removes the last element e such that
(o==null ? e==null : o.equals(e))
(if such an element exists).
Returns true if this deque contained the specified element
(or equivalently, if this deque changed as a result of the call).
|
public int | size()Returns the number of elements in this deque.
|