class PriorityQueue
source · line 9public class PriorityQueue<T> public constructor(
/**
* The comparator used for ordering and, for ordered maps/sets, equivalence.
*/
public val comparator: Comparator<T>) : Collection<T>
- Supertype
Collection<T>
A binary min-heap ordered by its comparator. Removal returns the smallest element; iteration exposes heap order, not sorted order. Structural changes invalidate iterators.
constructor constructor
source · line 9constructor(public val comparator: Comparator<T>)
parameter comparator
source · line 13public val comparator: Comparator<T>
function clear
source · line 117public fun clear(): Unit
Removes all elements.
property comparator
source · line 13public val comparator: Comparator<T>
get: public read-only
The comparator used for ordering and, for ordered maps/sets, equivalence.
function peek
source · line 64public fun peek(): T
Returns the smallest element without removal; an empty queue throws NoSuchElementException.
function add
source · line 41public fun add(element: T): Unit
Inserts an element while preserving the heap ordering.
parameter element
source · line 41element: T
function peekOrNone
source · line 72public fun peekOrNone(): T?
Returns the smallest element without removal, or None when empty.
function iterator
source · line 129public override operator fun iterator(): Iterator<T>
- Overrides
iterator
Iterates in heap storage order, which is not sorted; structural changes invalidate the iterator.
type parameter T
source · line 9T
function removeFirstOrNone
source · line 76public fun removeFirstOrNone(): T?
Removes the smallest element, or returns None when empty.
property size
source · line 20public override val size: Long
- Overrides
size
get: public read-only
The number of queued elements, including duplicates.
getter get
source · line 20get(): Long
function removeFirst
source · line 81public fun removeFirst(): T
Removes the smallest element; an empty queue throws NoSuchElementException.