Queue (Java SE 26 & JDK 26)
- Type Parameters:
E- the type of elements held in this queue
- All Superinterfaces:
Collection<E>, Iterable<E>
- All Known Subinterfaces:
BlockingDeque<E>, BlockingQueue<E>, Deque<E>, TransferQueue<E>
- All Known Implementing Classes:
AbstractQueue, ArrayBlockingQueue, ArrayDeque, ConcurrentLinkedDeque, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingDeque, LinkedBlockingQueue, LinkedList, LinkedTransferQueue, PriorityBlockingQueue, PriorityQueue, SynchronousQueue
-
Method Summary
booleanInserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning
trueupon success and throwing anIllegalStateExceptionif no space is currently available.element()Retrieves, but does not remove, the head of this queue.
booleanInserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
peek()Retrieves, but does not remove, the head of this queue, or returns
nullif this queue is empty.poll()Retrieves and removes the head of this queue, or returns
nullif this queue is empty.remove()Retrieves and removes the head of this queue.
Methods declared in interface Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArraybooleanAdds all of the elements in the specified collection to this collection (optional operation).
voidRemoves all of the elements from this collection (optional operation).
booleanReturns
trueif this collection contains the specified element.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 an iterator over the elements in this collection.
Returns a possibly parallel
Streamwith this collection as its source.booleanRemoves a single instance of the specified element from this collection, if it is present (optional operation).
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).
intReturns the number of elements in this collection.
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
-
add
-
offer
-
remove
-
poll
-
element
-
peek
-