v2026.5.3
All Bundles
Bundle Generic collections library: Vector (dynamic array), Map (hash map), Set, MultiMap, Stack, Queue, and Pair. Provides typed iteration, sorting, filtering, and functional operations (Reduce, Any, All). Compile with -lib gen_collect.

Queue

Queue of generics

# insert elements
queue := Collection.Queue->New()<String>;
queue->AddFront("San Francisco");
queue->AddBack("Oakland");
queue->AddBack("East Bay");
queue->AddBack("Mountain View");

# remove element
queue->RemoveBack();

# get size
queue->Size()->PrintLine();

# get value by key
queue->Back()->PrintLine();
queue->Front()->PrintLine();

Operations

AddBack #

Adds a value to the back of the queue

method : public : AddBack(value:H) ~ Nil

Parameters

NameTypeDescription
valueHvalue to add

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("first");
queue->AddBack("second");
queue->Back()->PrintLine(); # second

AddFront #

Adds a value to the front of the queue

method : public : AddFront(value:H) ~ Nil

Parameters

NameTypeDescription
valueHvalue to add

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("middle");
queue->AddFront("head");
queue->Front()->PrintLine(); # head

Back #

Get the value from the back of the queue

method : public : Back() ~ H

Return

TypeDescription
Hhead value, Nil if queue is empty

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("first");
queue->AddBack("last");
queue->Back()->PrintLine(); # last

Empty #

Clears the queue

method : public : Empty() ~ Nil

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("a");
queue->Empty();
queue->IsEmpty()->PrintLine(); # true

Front #

Get the value from the front of the queue

method : public : Front() ~ H

Return

TypeDescription
Hhead value, Nil if queue is empty

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("first");
queue->AddBack("last");
queue->Front()->PrintLine(); # first

IsEmpty #

Checks to see if the queue is empty

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty, false otherwise

Example

queue := Collection.Queue->New()<String>;
queue->IsEmpty()->PrintLine(); # true
queue->AddBack("x");
queue->IsEmpty()->PrintLine(); # false

New # constructor

Default constructor

New()

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("first");
queue->AddBack("second");
queue->Front()->PrintLine(); # first

RemoveBack #

Removes a value from the back of the queue

method : public : RemoveBack() ~ H

Return

TypeDescription
Hvalue removed

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("alpha");
queue->AddBack("beta");
queue->RemoveBack()->PrintLine(); # beta
queue->Back()->PrintLine();       # alpha

RemoveFront #

Removes a value from the front of the queue

method : public : RemoveFront() ~ H

Return

TypeDescription
Hvalue removed

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("first");
queue->AddBack("second");
queue->RemoveFront()->PrintLine(); # first
queue->Front()->PrintLine();       # second

Size #

Size of queue

method : public : Size() ~ Int

Return

TypeDescription
Intsize of queue

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("a");
queue->AddBack("b");
queue->Size()->PrintLine(); # 2

ToArray #

Converts the queue into an object array

method : public : ToArray() ~ H[]

Return

TypeDescription
H[]object array

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("a");
queue->AddBack("b");
arr := queue->ToArray();
arr[0]->PrintLine(); # a

ToString #

Formats the collection into a string. If an element implements the 'Stringify' interface, it's 'ToString()' is called.

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation

Example

queue := Collection.Queue->New()<String>;
queue->AddBack("a");
queue->AddBack("b");
queue->ToString()->PrintLine(); # [a,b]