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.
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.
|
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.
|
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, returning
true upon success and 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
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
Deque.offerFirst(E)
.public void addLast(E e)
java.util.Deque
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.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 addpublic 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
public E peekLast()
java.util.Deque
public E pollFirst()
java.util.Deque
public E pollLast()
java.util.Deque
public E pop()
java.util.Deque
This method is equivalent to Deque.removeFirst()
.
public void push(E e)
java.util.Deque
This method is equivalent to Deque.addFirst(E)
.
public E removeFirst()
java.util.Deque
pollFirst
only in that it throws an
exception if this deque is empty.removeFirst
in interface Deque<E>
public E removeLast()
java.util.Deque
pollLast
only in that it throws an
exception if this deque is empty.removeLast
in interface Deque<E>
public boolean removeFirstOccurrence(Object o)
java.util.Deque
removeFirstOccurrence
in interface Deque<E>
o
- element to be removed from this deque, if presentpublic boolean removeLastOccurrence(Object o)
java.util.Deque
removeLastOccurrence
in interface Deque<E>
o
- element to be removed from this deque, if presentCopyright © 2010-2014. All Rights Reserved.