Top Description Fields Constructors Methods
java.util

pack-priv Class ReverseOrderDequeView<E>

extends Object
implements Deque<E>
Class Inheritance
All Implemented Interfaces
java.util.Deque, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable, java.util.Queue
Imports
java.util.function.Consumer, .IntFunction, java.util.stream.Stream, .StreamSupport, jdk.internal.util.ArraysSupport

Provides a reverse-ordered view of any Deque. Not serializable.

Field Summary

Modifier and TypeField and Description
pack-priv final Deque<E>

Constructor Summary

AccessConstructor and Description
private

Method Summary

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

Implements java.util.Deque.add.

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.

public boolean
addAll(Collection<? extends E>
the elements to be inserted into this deque
c
)

Implements java.util.Deque.addAll.

Adds all of the elements in the specified collection at the end of this deque, as if by calling addLast on each one, in the order that they are returned by the collection's iterator.

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.

public void
clear()

Implements java.util.Collection.clear.

Removes all of the elements from this collection (optional operation).

public boolean
contains(Object
element whose presence in this deque is to be tested
o
)

Implements java.util.Deque.contains.

Returns true if this deque contains the specified element.

public boolean
containsAll(Collection<?>
collection to be checked for containment in this collection
c
)

Implements java.util.Collection.containsAll.

Returns true if this collection contains all of the elements in the specified collection.

public Iterator<E>
descendingIterator()

Implements java.util.Deque.descendingIterator.

Returns an iterator over the elements in this deque in reverse sequential order.

public E
element()

Implements java.util.Deque.element.

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque).

public void
forEach(Consumer<? super E>
The action to be performed for each element
action
)

Overrides default java.lang.Iterable.forEach.

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

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

Implements java.util.Collection.isEmpty.

Returns true if this collection contains no elements.

public Iterator<E>
iterator()

Implements java.util.Deque.iterator.

Returns an iterator over the elements in this deque in proper sequence.

public static <T> Deque<T>
of(Deque<T> deque)

public boolean
offer(E
the element to add
e
)

Implements java.util.Deque.offer.

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.

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 Stream<E>
parallelStream()

Overrides default java.util.Collection.parallelStream.

Returns a possibly parallel Stream with this collection as its source.

public E
peek()

Implements java.util.Deque.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.

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

Implements java.util.Deque.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.

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 boolean
remove(Object
element to be removed from this deque, if present
o
)

Implements java.util.Deque.remove.

Removes the first occurrence of the specified element from this deque.

public E
remove()

Implements java.util.Deque.remove.

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque).

public boolean
removeAll(Collection<?>
collection containing elements to be removed from this collection
c
)

Implements java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation).

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.

public boolean
retainAll(Collection<?>
collection containing elements to be retained in this collection
c
)

Implements java.util.Collection.retainAll.

Retains only the elements in this collection that are contained in the specified collection (optional operation).

public int
size()

Implements java.util.Deque.size.

Returns the number of elements in this deque.

public Spliterator<E>
spliterator()

Overrides default java.util.Collection.spliterator.

Creates a Spliterator over the elements in this collection.

public Stream<E>
stream()

Overrides default java.util.Collection.stream.

Returns a sequential Stream with this collection as its source.

public Object[]
toArray()

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection.

public <T> T[]
toArray(T[]
the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
a
)

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

public <T> T[]
toArray(IntFunction<T[]>
a function which produces a new array of the desired type and the provided length
generator
)

Overrides default java.util.Collection.toArray.

Returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

baseback to summary
pack-priv final Deque<E> base

Constructor Detail

ReverseOrderDequeViewback to summary
private ReverseOrderDequeView(Deque<E> deque)

Method Detail

addback to summary
public boolean add(E e)

Implements java.util.Deque.add.

Doc from java.util.Deque.add.

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 offer.

This method is equivalent to addLast.

Parameters
e:E

the element to add

Returns:boolean

true (as specified by Collection#add)

addAllback to summary
public boolean addAll(Collection<? extends E> c)

Implements java.util.Deque.addAll.

Doc from java.util.Deque.addAll.

Adds all of the elements in the specified collection at the end of this deque, as if by calling addLast on each one, in the order that they are returned by the collection's iterator.

When using a capacity-restricted deque, it is generally preferable to call offer separately on each element.

An exception encountered while trying to add an element may result in only some of the elements having been successfully added when the associated exception is thrown.

Parameters
c:Collection<? extends E>

the elements to be inserted into this deque

Returns:boolean

true if this deque changed as a result of the call

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

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

clearback to summary
public void clear()

Implements java.util.Collection.clear.

Doc from java.util.Collection.clear.

Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.

containsback to summary
public boolean contains(Object o)

Implements java.util.Deque.contains.

Doc from java.util.Deque.contains.

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

Parameters
o:Object

element whose presence in this deque is to be tested

Returns:boolean

true if this deque contains the specified element

containsAllback to summary
public boolean containsAll(Collection<?> c)

Implements java.util.Collection.containsAll.

Doc from java.util.Collection.containsAll.

Returns true if this collection contains all of the elements in the specified collection.

Parameters
c:Collection<?>

collection to be checked for containment in this collection

Returns:boolean

true if this collection contains all of the elements in the specified collection

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

elementback to summary
public E element()

Implements java.util.Deque.element.

Doc from java.util.Deque.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 peek only in that it throws an exception if this deque is empty.

This method is equivalent to getFirst().

Returns:E

the head of the queue represented by this deque

forEachback to summary
public void forEach(Consumer<? super E> action)

Overrides default java.lang.Iterable.forEach.

Doc from java.lang.Iterable.forEach.

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.

The behavior of this method is unspecified if the action performs side-effects that modify the underlying source of elements, unless an overriding class has specified a concurrent modification policy.

Parameters
action:Consumer<? super E>

The action to be performed for each element

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

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

isEmptyback to summary
public boolean isEmpty()

Implements java.util.Collection.isEmpty.

Doc from java.util.Collection.isEmpty.

Returns true if this collection contains no elements.

Returns:boolean

true if this collection contains no elements

iteratorback to summary
public Iterator<E> iterator()

Implements java.util.Deque.iterator.

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

Returns:Iterator<E>

an iterator over the elements in this deque in proper sequence

ofback to summary
public static <T> Deque<T> of(Deque<T> deque)
offerback to summary
public boolean offer(E e)

Implements java.util.Deque.offer.

Doc from java.util.Deque.offer.

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

This method is equivalent to offerLast.

Parameters
e:E

the element to add

Returns:boolean

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

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

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

parallelStreamback to summary
public Stream<E> parallelStream()

Overrides default java.util.Collection.parallelStream.

Doc from java.util.Collection.parallelStream.

Returns a possibly parallel Stream with this collection as its source. It is allowable for this method to return a sequential stream.

This method should be overridden when the spliterator() method cannot return a spliterator that is IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.)

Returns:Stream<E>

a possibly parallel Stream over the elements in this collection

peekback to summary
public E peek()

Implements java.util.Deque.peek.

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

Returns:E

the head of the queue represented by this deque, or null if this deque is empty

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

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

pollback to summary
public E poll()

Implements java.util.Deque.poll.

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

Returns:E

the first element of this deque, or null if this deque is empty

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

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

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)

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

removeback to summary
public boolean remove(Object o)

Implements java.util.Deque.remove.

Doc from java.util.Deque.remove.

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

This method is equivalent to removeFirstOccurrence(Object).

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

removeback to summary
public E remove()

Implements java.util.Deque.remove.

Doc from java.util.Deque.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 poll() only in that it throws an exception if this deque is empty.

This method is equivalent to removeFirst().

Returns:E

the head of the queue represented by this deque

removeAllback to summary
public boolean removeAll(Collection<?> c)

Implements java.util.Collection.removeAll.

Doc from java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.

Parameters
c:Collection<?>

collection containing elements to be removed from this collection

Returns:boolean

true if this collection changed as a result of the call

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

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

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

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

retainAllback to summary
public boolean retainAll(Collection<?> c)

Implements java.util.Collection.retainAll.

Doc from java.util.Collection.retainAll.

Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

Parameters
c:Collection<?>

collection containing elements to be retained in this collection

Returns:boolean

true if this collection changed as a result of the call

sizeback to summary
public int size()

Implements java.util.Deque.size.

Doc from java.util.Deque.size.

Returns the number of elements in this deque.

Returns:int

the number of elements in this deque

spliteratorback to summary
public Spliterator<E> spliterator()

Overrides default java.util.Collection.spliterator.

Doc from java.util.Collection.spliterator.

Creates a Spliterator over the elements in this collection. Implementations should document characteristic values reported by the spliterator. Such characteristic values are not required to be reported if the spliterator reports Spliterator#SIZED and this collection contains no elements.

The default implementation should be overridden by subclasses that can return a more efficient spliterator. In order to preserve expected laziness behavior for the stream() and parallelStream() methods, spliterators should either have the characteristic of IMMUTABLE or CONCURRENT, or be late-binding. If none of these is practical, the overriding class should describe the spliterator's documented policy of binding and structural interference, and should override the stream() and parallelStream() methods to create streams using a Supplier of the spliterator, as in:

Stream<E> s = StreamSupport.stream(() -> spliterator(), spliteratorCharacteristics)

These requirements ensure that streams produced by the stream() and parallelStream() methods will reflect the contents of the collection as of initiation of the terminal stream operation.

Returns:Spliterator<E>

a Spliterator over the elements in this collection

streamback to summary
public Stream<E> stream()

Overrides default java.util.Collection.stream.

Doc from java.util.Collection.stream.

Returns a sequential Stream with this collection as its source.

This method should be overridden when the spliterator() method cannot return a spliterator that is IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.)

Returns:Stream<E>

a sequential Stream over the elements in this collection

toArrayback to summary
public Object[] toArray()

Implements java.util.Collection.toArray.

Doc from java.util.Collection.toArray.

Returns an array containing all of the elements in this collection. If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array's runtime component type is Object.

The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.

Returns:Object[]

an array, whose runtime component type is Object, containing all of the elements in this collection

toArrayback to summary
public <T> T[] toArray(T[] a)

Implements java.util.Collection.toArray.

Doc from java.util.Collection.toArray.

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.

If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.)

If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

Parameters
<T>
the component type of the array to contain the collection
a:T[]

the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.

Returns:T[]

an array containing all of the elements in this collection

Annotations
@SuppressWarnings:unchecked
toArrayback to summary
public <T> T[] toArray(IntFunction<T[]> generator)

Overrides default java.util.Collection.toArray.

Doc from java.util.Collection.toArray.

Returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.

If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

Parameters
<T>
the component type of the array to contain the collection
generator:IntFunction<T[]>

a function which produces a new array of the desired type and the provided length

Returns:T[]

an array containing all of the elements in this collection

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object