PriorityQueue (Java SE 25 & JDK 25)
- Type Parameters:
E- the type of elements held in this queue
- All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Queue<E>
-
Constructor Summary
Constructors
Creates a
PriorityQueuewith the default initial capacity (11) that orders its elements according to their natural ordering.PriorityQueue(int initialCapacity) Creates a
PriorityQueuewith the specified initial capacity that orders its elements according to their natural ordering.PriorityQueue(int initialCapacity, Comparator<? super E> comparator) Creates a
PriorityQueuewith the specified initial capacity that orders its elements according to the specified comparator.Creates a
PriorityQueuecontaining the elements in the specified collection.Creates a
PriorityQueuewith the default initial capacity and whose elements are ordered according to the specified comparator.Creates a
PriorityQueuecontaining the elements in the specified priority queue.Creates a
PriorityQueuecontaining the elements in the specified sorted set. -
Method Summary
booleanInserts the specified element into this priority queue.
voidclear()Removes all of the elements from this priority queue.
Returns the comparator used to order the elements in this queue, or
nullif this queue is sorted according to the natural ordering of its elements.booleanReturns
trueif this queue contains the specified element.voidPerforms the given action for each element of the
Iterableuntil all elements have been processed or the action throws an exception.iterator()Returns an iterator over the elements in this queue.
booleanInserts the specified element into this priority queue.
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.booleanRemoves a single instance of the specified element from this queue, if it is present.
booleanRemoves all of this collection's elements that are also contained in the specified collection (optional operation).
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).
intsize()Returns the number of elements in this collection.
toArray()Returns an array containing all of the elements in this queue.
<T> T[]toArray(T[] a) Returns an array containing all of the elements in this queue; the runtime type of the returned array is that of the specified array.
-
Constructor Details
-
PriorityQueue
-
PriorityQueue
-
PriorityQueue
-
PriorityQueue
-
PriorityQueue
-
PriorityQueue
-
PriorityQueue
-
-
Method Details
-
add
-
offer
-
peek
-
remove
-
contains
-
toArray
-
toArray
-
iterator
-
size
-
clear
-
poll
-
comparator
-
spliterator
-
removeIf
-
removeAll
-
retainAll
-
forEach
-