com.google.common.collect
Class ForwardingDeque<E>

java.lang.Object
  extended by com.google.common.collect.ForwardingObject
      extended by com.google.common.collect.ForwardingCollection<E>
          extended by com.google.common.collect.ForwardingQueue<E>
              extended by com.google.common.collect.ForwardingDeque<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.Deque<E>, java.util.Queue<E>
Direct Known Subclasses:
ForwardingBlockingDeque

public abstract class ForwardingDeque<E>
extends ForwardingQueue<E>
implements java.util.Deque<E>

A deque which forwards all its method calls to another deque. Subclasses should override one or more methods to modify the behavior of the backing deque as desired per the decorator pattern.

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.

Since:
12.0

Constructor Summary
protected ForwardingDeque()
          Constructor for use by subclasses.
 
Method Summary
 void addFirst(E e)
           
 void addLast(E e)
           
protected abstract  java.util.Deque<E> delegate()
          Returns the backing delegate instance that methods are forwarded to.
 java.util.Iterator<E> descendingIterator()
           
 E getFirst()
           
 E getLast()
           
 boolean offerFirst(E e)
           
 boolean offerLast(E e)
           
 E peekFirst()
           
 E peekLast()
           
 E pollFirst()
           
 E pollLast()
           
 E pop()
           
 void push(E e)
           
 E removeFirst()
           
 boolean removeFirstOccurrence(java.lang.Object o)
           
 E removeLast()
           
 boolean removeLastOccurrence(java.lang.Object o)
           
 
Methods inherited from class com.google.common.collect.ForwardingQueue
element, offer, peek, poll, remove, standardOffer, standardPeek, standardPoll
 
Methods inherited from class com.google.common.collect.ForwardingCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRemoveAll, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray
 
Methods inherited from class com.google.common.collect.ForwardingObject
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Deque
add, contains, element, iterator, offer, peek, poll, remove, remove, size
 
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Constructor Detail

ForwardingDeque

protected ForwardingDeque()
Constructor for use by subclasses.

Method Detail

delegate

protected abstract java.util.Deque<E> delegate()
Description copied from class: ForwardingObject
Returns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such as ForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.

Specified by:
delegate in class ForwardingQueue<E>

addFirst

public void addFirst(E e)
Specified by:
addFirst in interface java.util.Deque<E>

addLast

public void addLast(E e)
Specified by:
addLast in interface java.util.Deque<E>

descendingIterator

public java.util.Iterator<E> descendingIterator()
Specified by:
descendingIterator in interface java.util.Deque<E>

getFirst

public E getFirst()
Specified by:
getFirst in interface java.util.Deque<E>

getLast

public E getLast()
Specified by:
getLast in interface java.util.Deque<E>

offerFirst

public boolean offerFirst(E e)
Specified by:
offerFirst in interface java.util.Deque<E>

offerLast

public boolean offerLast(E e)
Specified by:
offerLast in interface java.util.Deque<E>

peekFirst

public E peekFirst()
Specified by:
peekFirst in interface java.util.Deque<E>

peekLast

public E peekLast()
Specified by:
peekLast in interface java.util.Deque<E>

pollFirst

public E pollFirst()
Specified by:
pollFirst in interface java.util.Deque<E>

pollLast

public E pollLast()
Specified by:
pollLast in interface java.util.Deque<E>

pop

public E pop()
Specified by:
pop in interface java.util.Deque<E>

push

public void push(E e)
Specified by:
push in interface java.util.Deque<E>

removeFirst

public E removeFirst()
Specified by:
removeFirst in interface java.util.Deque<E>

removeLast

public E removeLast()
Specified by:
removeLast in interface java.util.Deque<E>

removeFirstOccurrence

public boolean removeFirstOccurrence(java.lang.Object o)
Specified by:
removeFirstOccurrence in interface java.util.Deque<E>

removeLastOccurrence

public boolean removeLastOccurrence(java.lang.Object o)
Specified by:
removeLastOccurrence in interface java.util.Deque<E>