ArrayDeque (Java SE 26 & JDK 26)
- Type Parameters:
E- the type of elements held in this deque
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, Queue<E>, SequencedCollection<E>
-
Constructor Summary
Constructors
Constructs an empty array deque with an initial capacity sufficient to hold 16 elements.
ArrayDeque(int numElements) Constructs an empty array deque with an initial capacity sufficient to hold the specified number of elements.
Constructs a deque containing the elements of the specified collection, in the order they are returned by the collection's iterator.
-
Method Summary
booleanInserts the specified element at the end of this deque.
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.
voidInserts the specified element at the end of this deque.
voidclear()Removes all of the elements from this deque.
clone()Returns a copy of this deque.
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.
voidPerforms the given action for each element of the
Iterableuntil all elements have been processed or the action throws an exception.getFirst()Retrieves, but does not remove, the first element of this deque.
getLast()Retrieves, but does not remove, the last element of this deque.
booleanisEmpty()Returns
trueif this deque contains no elements.iterator()Returns an iterator over the elements in this deque.
booleanInserts the specified element at the end of this deque.
booleanofferFirst(E e) Inserts the specified element at the front of this deque.
booleanInserts the specified element at the end of this deque.
peek()Retrieves, but does not remove, the head of the queue represented by 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.
remove()Retrieves and removes the head of the queue represented by this deque.
booleanRemoves a single instance of the specified element from this deque.
booleanRemoves all of this collection's elements that are also contained in the specified collection (optional operation).
Retrieves and removes the first element of this deque.
booleanRemoves the first occurrence of the specified element in this deque (when traversing the deque from head to tail).
booleanRemoves all of the elements of this collection that satisfy the given predicate (optional operation).
Retrieves and removes the last element of this deque.
booleanRemoves the last occurrence of the specified element in this deque (when traversing the deque from head to tail).
booleanRetains only the elements in this collection that are contained in the specified collection (optional operation).
intsize()Returns the number of elements in this deque.
toArray()Returns an array containing all of the elements in this deque in proper sequence (from first to last element).
<T> T[]toArray(T[] a) Returns an array containing all of the elements in this deque in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.
Methods declared in class AbstractCollection
booleanReturns
trueif this collection contains all of the elements in the specified collection.Returns a string representation of this collection.
Methods declared in class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbooleanIndicates whether some other object is "equal to" this one.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.intReturns a hash code value for this object.
final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
Methods declared in interface Collection
equals, hashCode, parallelStream, stream, toArraybooleanCompares the specified object with this collection for equality.
intReturns the hash code value for this collection.
Returns a possibly parallel
Streamwith this collection as its source.Returns a sequential
Streamwith this collection as its source.default <T> T[]Returns an array containing all of the elements in this collection, using the provided
generatorfunction to allocate the returned array.
-
Constructor Details
-
ArrayDeque
-
ArrayDeque
-
ArrayDeque
-
-
Method Details
-
addFirst
-
addLast
-
addAll
-
offerFirst
-
offerLast
-
removeFirst
-
removeLast
-
pollFirst
-
pollLast
-
getFirst
-
getLast
-
peekFirst
-
peekLast
-
removeFirstOccurrence
-
removeLastOccurrence
-
add
-
offer
-
remove
-
poll
-
element
-
peek
-
push
-
pop
-
size
-
isEmpty
-
iterator
-
descendingIterator
-
spliterator
-
forEach
-
removeIf
-
removeAll
-
retainAll
-
contains
-
remove
-
clear
-
toArray
-
toArray
-
clone
-