Skip to content
FutureBlitz

    Install

    Import std.collections.queue

    std.collections.queue

    A first-in, first-out queue.

    Enqueue puts a value at the back, and Dequeue takes the one at the front. The values start at Head. Dequeue empties a value's slot as it takes it, so the value goes once the program lets go of it, and the empty slots are dropped once they're half.

    std/collections/queue.fb

    Types

    Queue class

    @DebugElements Public Class Queue<T> Implements Iterable<T>, Cloneable, Defaultable

    First in, first out: Enqueue puts a value at the back, and Dequeue takes the front one off.

    Examples

    Local turns = Queue<String>()
    turns.Enqueue("knight")
    turns.Enqueue("goblin")
    Expect(turns.Dequeue() == "knight")
    Expect(turns.Peek() == "goblin")

    std/collections/queue.fb, line 20

    • Public Property Count: Int property #

      How many values it holds.

    • Public Method Enqueue(value: T) method #

      Puts value at the back.

    • Public Method Add(value: T) method #

      The same as Enqueue.

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

      Enqueues each of the values, in order.

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

      Takes the front value off and gives it. Panics when the Queue is empty.

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

      The front value, which stays. Panics when the Queue is empty.

    • Public Method TryDequeue(): T? method #

      Takes the front value off and gives it, or Null when the Queue is empty.

    • Public Method TryPeek(): T? method #

      The front value, which stays, or Null when the Queue is empty.

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

      The values from the front, the order Dequeue gives them, in a new array.

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

      Whether it holds value.

    • Public Method Clear() method #

      Takes every value out.

    • Public Static Method DefaultValue(): Queue<T> static method #

      A new, empty Queue.

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

      A new Queue with the same values.

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

      The values from the front, the order Dequeue gives them. Changing the Queue while going over them panics.

    QueueIterator struct

    Public Struct QueueIterator<T> Implements Iterator<T>

    The values of a Queue, front first, which a For loop goes over.

    std/collections/queue.fb, line 130

    • @PanicsAtCaller Public ByRef Method Next(): T? method #

      The next value, from the front to the back, or Null after the last. Panics when the Queue changed since the loop began.

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