@GwtIncompatible public abstract class ForwardingDeque<E> extends ForwardingQueue<E> implements Deque<E>
Warning: The methods of ForwardingDeque
forward indiscriminately to the
methods of the delegate. For example, overriding ForwardingCollection.add(E)
alone will not change the
behavior of ForwardingQueue.offer(E)
which can lead to unexpected behavior. In this case, you should
override offer
as well.
default
method warning: This class does not forward calls to default
methods. Instead, it inherits their default implementations. When those implementations
invoke methods, they invoke methods on the ForwardingDeque
.
Modifier | Constructor and Description |
---|---|
protected |
ForwardingDeque()
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
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,
throwing an
IllegalStateException if no space is currently
available. |
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,
throwing an
IllegalStateException if no space is currently
available. |
protected abstract Deque<E> |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
Iterator<E> |
descendingIterator()
Returns an iterator over the elements in this deque in reverse
sequential order.
|
E |
getFirst()
Retrieves, but does not remove, the first element of this deque.
|
E |
getLast()
Retrieves, but does not remove, the last element of this deque.
|
boolean |
offerFirst(E e)
Inserts the specified element at the front of this deque unless it would
violate capacity restrictions.
|
boolean |
offerLast(E e)
Inserts the specified element at the end of this deque unless it would
violate capacity restrictions.
|
E |
peekFirst()
Retrieves, but does not remove, the first element of this deque,
or returns
null if this deque is empty. |
E |
peekLast()
Retrieves, but does not remove, the last element of this deque,
or returns
null if this deque is empty. |
E |
pollFirst()
Retrieves and removes the first element of this deque,
or returns
null if this deque is empty. |
E |
pollLast()
Retrieves and removes the last element of this deque,
or returns
null if this deque is empty. |
E |
pop()
Pops an element from the stack represented by this deque.
|
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, throwing an
IllegalStateException if no space is currently available. |
E |
removeFirst()
Retrieves and removes the first element of this deque.
|
boolean |
removeFirstOccurrence(Object o)
Removes the first occurrence of the specified element from this deque.
|
E |
removeLast()
Retrieves and removes the last element of this deque.
|
boolean |
removeLastOccurrence(Object o)
Removes the last occurrence of the specified element from this deque.
|
element, offer, peek, poll, remove, standardOffer, standardPeek, standardPoll
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRemoveAll, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray
toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, contains, element, iterator, offer, peek, poll, remove, remove, size
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
protected ForwardingDeque()
protected abstract Deque<E> delegate()
ForwardingObject
ForwardingSet.delegate()
. Concrete subclasses override this method to supply the
instance being decorated.delegate
in class ForwardingQueue<E>
public void addFirst(E e)
java.util.Deque
IllegalStateException
if no space is currently
available. When using a capacity-restricted deque, it is generally
preferable to use method Deque.offerFirst(E)
.public void addLast(E e)
java.util.Deque
IllegalStateException
if no space is currently
available. When using a capacity-restricted deque, it is generally
preferable to use method Deque.offerLast(E)
.
This method is equivalent to Deque.add(E)
.
public Iterator<E> descendingIterator()
java.util.Deque
descendingIterator
in interface Deque<E>
public E getFirst()
java.util.Deque
peekFirst
only in that it
throws an exception if this deque is empty.public E getLast()
java.util.Deque
peekLast
only in that it
throws an exception if this deque is empty.@CanIgnoreReturnValue public boolean offerFirst(E e)
java.util.Deque
Deque.addFirst(E)
method,
which can fail to insert an element only by throwing an exception.offerFirst
in interface Deque<E>
e
- the element to addtrue
if the element was added to this deque, else
false
@CanIgnoreReturnValue public boolean offerLast(E e)
java.util.Deque
Deque.addLast(E)
method,
which can fail to insert an element only by throwing an exception.public E peekFirst()
java.util.Deque
null
if this deque is empty.public E peekLast()
java.util.Deque
null
if this deque is empty.@CanIgnoreReturnValue public E pollFirst()
java.util.Deque
null
if this deque is empty.@CanIgnoreReturnValue public E pollLast()
java.util.Deque
null
if this deque is empty.@CanIgnoreReturnValue public E pop()
java.util.Deque
This method is equivalent to Deque.removeFirst()
.
public void push(E e)
java.util.Deque
IllegalStateException
if no space is currently available.
This method is equivalent to Deque.addFirst(E)
.
@CanIgnoreReturnValue public E removeFirst()
java.util.Deque
pollFirst
only in that it throws an
exception if this deque is empty.removeFirst
in interface Deque<E>
@CanIgnoreReturnValue public E removeLast()
java.util.Deque
pollLast
only in that it throws an
exception if this deque is empty.removeLast
in interface Deque<E>
@CanIgnoreReturnValue public boolean removeFirstOccurrence(Object o)
java.util.Deque
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).removeFirstOccurrence
in interface Deque<E>
o
- element to be removed from this deque, if presenttrue
if an element was removed as a result of this call@CanIgnoreReturnValue public boolean removeLastOccurrence(Object o)
java.util.Deque
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).removeLastOccurrence
in interface Deque<E>
o
- element to be removed from this deque, if presenttrue
if an element was removed as a result of this callCopyright © 2010–2017. All rights reserved.