Top Description Constructors Methods
com.google.common.collect

public abstract Class ForwardingDeque<E extends @Nullable Object>

extends ForwardingQueue<E extends @Nullable Object>
implements Deque<E extends @Nullable Object>
Class Inheritance
All Implemented Interfaces
java.util.Deque, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable, java.util.Queue
Known Direct Subclasses
com.google.common.util.concurrent.ForwardingBlockingDeque, com.google.common.collect.ForwardingBlockingDeque
Annotations
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtIncompatible, .J2ktIncompatible, com.google.errorprone.annotations.CanIgnoreReturnValue, java.util.Deque, .Iterator, javax.annotation.CheckForNull, org.checkerframework.checker.nullness.qual.Nullable

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 add alone will not change the behavior of offer 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.

Author
Kurt Alfred Kluever
Since
12.0

Constructor Summary

AccessConstructor and Description
protected
ForwardingDeque()

Constructor for use by subclasses.

Method Summary

Modifier and TypeMethod and Description
public void
addFirst(E
the element to add
e
)

Implements java.util.Deque.addFirst.

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.
public void
addLast(E
the element to add
e
)

Implements java.util.Deque.addLast.

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()

Implements abstract com.google.common.collect.ForwardingQueue.delegate.

Returns the backing delegate instance that methods are forwarded to.
public Iterator<E>
descendingIterator()

Implements java.util.Deque.descendingIterator.

Returns an iterator over the elements in this deque in reverse sequential order.
public E
getFirst()

Implements java.util.Deque.getFirst.

Retrieves, but does not remove, the first element of this deque.
public E
getLast()

Implements java.util.Deque.getLast.

Retrieves, but does not remove, the last element of this deque.
public boolean
offerFirst(E
the element to add
e
)

Implements java.util.Deque.offerFirst.

Inserts the specified element at the front of this deque unless it would violate capacity restrictions.
public boolean
offerLast(E
the element to add
e
)

Implements java.util.Deque.offerLast.

Inserts the specified element at the end of this deque unless it would violate capacity restrictions.
public E
peekFirst()

Implements java.util.Deque.peekFirst.

Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.
public E
peekLast()

Implements java.util.Deque.peekLast.

Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.
public E
pollFirst()

Implements java.util.Deque.pollFirst.

Retrieves and removes the first element of this deque, or returns null if this deque is empty.
public E
pollLast()

Implements java.util.Deque.pollLast.

Retrieves and removes the last element of this deque, or returns null if this deque is empty.
public E
pop()

Implements java.util.Deque.pop.

Pops an element from the stack represented by this deque.
public void
push(E
the element to push
e
)

Implements java.util.Deque.push.

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.
public E
removeFirst()

Implements java.util.Deque.removeFirst.

Retrieves and removes the first element of this deque.
public boolean
removeFirstOccurrence(Object
element to be removed from this deque, if present
o
)

Implements java.util.Deque.removeFirstOccurrence.

Removes the first occurrence of the specified element from this deque.
public E
removeLast()

Implements java.util.Deque.removeLast.

Retrieves and removes the last element of this deque.
public boolean
removeLastOccurrence(Object
element to be removed from this deque, if present
o
)

Implements java.util.Deque.removeLastOccurrence.

Removes the last occurrence of the specified element from this deque.
Inherited from com.google.common.collect.ForwardingQueue:
elementofferpeekpollremovestandardOfferstandardPeekstandardPoll

Constructor Detail

ForwardingDequeback to summary
protected ForwardingDeque()

Constructor for use by subclasses.

Method Detail

addFirstback to summary
public void addFirst(E e)

Implements java.util.Deque.addFirst.

Doc from java.util.Deque.addFirst.

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. When using a capacity-restricted deque, it is generally preferable to use method offerFirst.

Parameters
e:E

the element to add

Annotations
@Override
addLastback to summary
public void addLast(E e)

Implements java.util.Deque.addLast.

Doc from java.util.Deque.addLast.

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. When using a capacity-restricted deque, it is generally preferable to use method offerLast.

This method is equivalent to add.

Parameters
e:E

the element to add

Annotations
@Override
delegateback to summary
protected abstract Deque<E> delegate()

Implements abstract com.google.common.collect.ForwardingQueue.delegate.

Doc from com.google.common.collect.ForwardingObject.delegate.

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.

Annotations
@Override
descendingIteratorback to summary
public Iterator<E> descendingIterator()

Implements java.util.Deque.descendingIterator.

Doc from java.util.Deque.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).

Returns:Iterator<E>

an iterator over the elements in this deque in reverse sequence

Annotations
@Override
getFirstback to summary
public E getFirst()

Implements java.util.Deque.getFirst.

Doc from java.util.Deque.getFirst.

Retrieves, but does not remove, the first element of this deque. This method differs from peekFirst only in that it throws an exception if this deque is empty.

Returns:E

the head of this deque

Annotations
@Override
@ParametricNullness
getLastback to summary
public E getLast()

Implements java.util.Deque.getLast.

Doc from java.util.Deque.getLast.

Retrieves, but does not remove, the last element of this deque. This method differs from peekLast only in that it throws an exception if this deque is empty.

Returns:E

the tail of this deque

Annotations
@Override
@ParametricNullness
offerFirstback to summary
public boolean offerFirst(E e)

Implements java.util.Deque.offerFirst.

Doc from java.util.Deque.offerFirst.

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 addFirst method, which can fail to insert an element only by throwing an exception.

Parameters
e:E

the element to add

Returns:boolean

true if the element was added to this deque, else false

Annotations
@CanIgnoreReturnValue
@Override
offerLastback to summary
public boolean offerLast(E e)

Implements java.util.Deque.offerLast.

Doc from java.util.Deque.offerLast.

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 addLast method, which can fail to insert an element only by throwing an exception.

Parameters
e:E

the element to add

Returns:boolean

true if the element was added to this deque, else false

Annotations
@CanIgnoreReturnValue
@Override
peekFirstback to summary
public E peekFirst()

Implements java.util.Deque.peekFirst.

Doc from java.util.Deque.peekFirst.

Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.

Returns:E

the head of this deque, or null if this deque is empty

Annotations
@Override
@CheckForNull
peekLastback to summary
public E peekLast()

Implements java.util.Deque.peekLast.

Doc from java.util.Deque.peekLast.

Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.

Returns:E

the tail of this deque, or null if this deque is empty

Annotations
@Override
@CheckForNull
pollFirstback to summary
public E pollFirst()

Implements java.util.Deque.pollFirst.

Doc from java.util.Deque.pollFirst.

Retrieves and removes the first element of this deque, or returns null if this deque is empty.

Returns:E

the head of this deque, or null if this deque is empty

Annotations
@CanIgnoreReturnValue
@Override
@CheckForNull
pollLastback to summary
public E pollLast()

Implements java.util.Deque.pollLast.

Doc from java.util.Deque.pollLast.

Retrieves and removes the last element of this deque, or returns null if this deque is empty.

Returns:E

the tail of this deque, or null if this deque is empty

Annotations
@CanIgnoreReturnValue
@Override
@CheckForNull
popback to summary
public E pop()

Implements java.util.Deque.pop.

Doc from java.util.Deque.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 removeFirst().

Returns:E

the element at the front of this deque (which is the top of the stack represented by this deque)

Annotations
@CanIgnoreReturnValue
@Override
@ParametricNullness
pushback to summary
public void push(E e)

Implements java.util.Deque.push.

Doc from java.util.Deque.push.

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.

This method is equivalent to addFirst.

Parameters
e:E

the element to push

Annotations
@Override
removeFirstback to summary
public E removeFirst()

Implements java.util.Deque.removeFirst.

Doc from java.util.Deque.removeFirst.

Retrieves and removes the first element of this deque. This method differs from pollFirst only in that it throws an exception if this deque is empty.

Returns:E

the head of this deque

Annotations
@CanIgnoreReturnValue
@Override
@ParametricNullness
removeFirstOccurrenceback to summary
public boolean removeFirstOccurrence(Object o)

Implements java.util.Deque.removeFirstOccurrence.

Doc from java.util.Deque.removeFirstOccurrence.

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 Objects.equals(o, 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).

Parameters
o:Object

element to be removed from this deque, if present

Returns:boolean

true if an element was removed as a result of this call

Annotations
@CanIgnoreReturnValue
@Override
removeLastback to summary
public E removeLast()

Implements java.util.Deque.removeLast.

Doc from java.util.Deque.removeLast.

Retrieves and removes the last element of this deque. This method differs from pollLast only in that it throws an exception if this deque is empty.

Returns:E

the tail of this deque

Annotations
@CanIgnoreReturnValue
@Override
@ParametricNullness
removeLastOccurrenceback to summary
public boolean removeLastOccurrence(Object o)

Implements java.util.Deque.removeLastOccurrence.

Doc from java.util.Deque.removeLastOccurrence.

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 Objects.equals(o, 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).

Parameters
o:Object

element to be removed from this deque, if present

Returns:boolean

true if an element was removed as a result of this call

Annotations
@CanIgnoreReturnValue
@Override