Skip to content
FutureBlitz

    Install

    Import std.collections.priority_queue

    std.collections.priority_queue

    PriorityQueue<T>: Pop gives the value that comes first, the smallest unless a before function says what comes first. The values are a binary heap: each one comes before its two children, at 2i + 1 and 2i + 2. In the smallest-first order, a value that isn't equal to itself, like NaN, panics where it's added, as with SortedSet, since the order can't place it.

    std/collections/priority_queue.fb

    Types

    PriorityQueue class

    @DebugElements Public Class PriorityQueue<T> Implements Iterable<T>, Cloneable

    A heap that gives its values out first by a priority: the smallest first, or what a Function says comes first.

    std/collections/priority_queue.fb, line 11

    • Public New() constructor #

      A new, empty PriorityQueue that gives its smallest value first.

    • Public New(before: Func(T, T): Bool) constructor #

      A new, empty PriorityQueue that gives first the value before says comes before the others.

    • Public Property Count: Int property #

      How many values it holds.

    • @PanicsAtCaller Public Method Add(value: T) method #

      Puts value in.

    • @PanicsAtCaller Public Method AddAll(values: Iterable<T>) method #

      Adds each of the values, putting the heap in order once, in time that grows with the count.

    • @PanicsAtCaller Public Method Pop(): T method #

      Takes the first value off and gives it. Panics when the PriorityQueue is empty.

    • Public Method TryPop(): T? method #

      Takes the first value off and gives it, or Null when the PriorityQueue is empty.

    • Public Method TryPeek(): T? method #

      The first value, which stays, or Null when the PriorityQueue is empty.

    • Public Method Drain(): T[] method #

      Takes every value off, and gives them in the order Pop would.

    • Public Method ToArray(): T[] method #

      The values, in no particular order, in a new array.

    • @PanicsAtCaller Public Method Peek(): T method #

      The first value, which stays. Panics when the PriorityQueue is empty.

    • Public Method Contains(value: T): Bool method #

      Whether it holds value.

    • Public Method Clear() method #

      Takes every value out.

    • Public Method Clone(): PriorityQueue<T> method #

      A new PriorityQueue with the same values and order.

    • Public Method Iterate(): PriorityQueueIterator<T> method #

      The values, in no particular order: Pop gives them in order. Changing the PriorityQueue while going over them panics.

    PriorityQueueIterator struct

    Public Struct PriorityQueueIterator<T> Implements Iterator<T>

    The values of a PriorityQueue, in no order to count on, which For ... In goes over.

    std/collections/priority_queue.fb, line 179

    Extends

    PriorityQueue extend

    Extend PriorityQueue<T> Implements Defaultable

    No doc comment.

    std/collections/priority_queue.fb, line 172

    Report an issue with this page or with FutureBlitz on GitHub.