PriorityQueue¶
Import: import system.collections;
Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.
PriorityQueue¶
Four-child min-heap: pop/peek always return the smallest element by the active comparator (natural ascending order via Comparable<T> by default, or a custom fun(T, T): int).
constructor¶
Empty queue ordered by T's natural Comparable order.
constructor¶
Empty queue ordered by a custom comparator (same contract as List.sort_by: negative when a should come out first, positive when b should).
length¶
Number of elements currently stored.
is_empty¶
True when the queue has no elements.
clear¶
Removes every element. Live slots are overwritten with a zero value so managed elements release immediately instead of staying retained until later pushes overwrite them.
clear¶
Unmanaged: no RC to release — rewind only.
push¶
Adds a value to the priority queue.
pop¶
Removes the highest-priority value, or returns None when empty.
peek¶
Returns the smallest element without removing it, or None when empty. O(1).
iterator¶
Iterates elements in ascending order under the active comparator, over a snapshot taken now, so later pushes/pops do not affect the cursor.