Deque (Java SE 26 & JDK 26)
- Type Parameters:
E- the type of elements held in this deque
- All Superinterfaces:
Collection<E>, Iterable<E>, Queue<E>, SequencedCollection<E>
- All Known Subinterfaces:
BlockingDeque<E>
- All Known Implementing Classes:
ArrayDeque, ConcurrentLinkedDeque, LinkedBlockingDeque, LinkedList
-
Method Summary
booleanInserts 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
trueupon success and throwing anIllegalStateExceptionif no space is currently available.booleanAdds all of the elements in the specified collection at the end of this deque, as if by calling
addLast(E)on each one, in the order that they are returned by the collection's iterator.voidInserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an
IllegalStateExceptionif no space is currently available.voidInserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an
IllegalStateExceptionif no space is currently available.booleanReturns
trueif this deque contains the specified element.Returns an iterator over the elements in this deque in reverse sequential order.
element()Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque).
getFirst()Retrieves, but does not remove, the first element of this deque.
getLast()Retrieves, but does not remove, the last element of this deque.
iterator()Returns an iterator over the elements in this deque in proper sequence.
booleanInserts 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
trueupon success andfalseif no space is currently available.booleanofferFirst(E e) Inserts the specified element at the front of this deque unless it would violate capacity restrictions.
booleanInserts the specified element at the end of this deque unless it would violate capacity restrictions.
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
nullif this deque is empty.Retrieves, but does not remove, the first element of this deque, or returns
nullif this deque is empty.peekLast()Retrieves, but does not remove, the last element of this deque, or returns
nullif this deque is empty.poll()Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns
nullif this deque is empty.Retrieves and removes the first element of this deque, or returns
nullif this deque is empty.pollLast()Retrieves and removes the last element of this deque, or returns
nullif this deque is empty.pop()Pops an element from the stack represented by this deque.
voidPushes 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
IllegalStateExceptionif no space is currently available.remove()Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque).
booleanRemoves the first occurrence of the specified element from this deque.
Retrieves and removes the first element of this deque.
booleanRemoves the first occurrence of the specified element from this deque.
Retrieves and removes the last element of this deque.
booleanRemoves the last occurrence of the specified element from this deque.
reversed()Returns a reverse-ordered view of this collection.
intsize()Returns the number of elements in this deque.
Methods declared in interface Collection
clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArrayvoidRemoves all of the elements from this collection (optional operation).
booleanReturns
trueif this collection contains all of the elements in the specified collection.booleanCompares the specified object with this collection for equality.
intReturns the hash code value for this collection.
booleanReturns
trueif this collection contains no elements.Returns a possibly parallel
Streamwith this collection as its source.booleanRemoves all of this collection's elements that are also contained in the specified collection (optional operation).
default booleanRemoves all of the elements of this collection that satisfy the given predicate (optional operation).
booleanRetains only the elements in this collection that are contained in the specified collection (optional operation).
Creates a
Spliteratorover the elements in this collection.Returns a sequential
Streamwith this collection as its source.Returns an array containing all of the elements in this collection.
default <T> T[]Returns an array containing all of the elements in this collection, using the provided
generatorfunction to allocate the returned array.<T> T[]Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
-
Method Details
-
addFirst
-
addLast
-
offerFirst
-
offerLast
-
removeFirst
-
removeLast
-
pollFirst
-
pollLast
-
getFirst
-
getLast
-
peekFirst
-
peekLast
-
removeFirstOccurrence
-
removeLastOccurrence
-
add
-
offer
-
remove
-
poll
-
element
-
peek
-
addAll
-
push
-
pop
-
remove
-
contains
-
size
-
iterator
-
descendingIterator
-
reversed
-