v2026.11.3
All Bundles
Bundle

Generic collections library: Vector (dynamic array), List (linked list), Map (ordered binary tree, O(log n)), Hash (hash table), Set, HashSet, SetHash, MultiMap, MultiHash, Stack, Queue, and Pair. Provides typed iteration, sorting, filtering, and functional operations (Reduce, Any, All). Compile with -lib gen_collect.

Deque

Double-ended queue backed by a ring buffer: O(1) amortised at both ends and O(1) index access. Unlike List there is no cursor; unlike Vector, AddFront and RemoveFront are O(1).

Operations

AddBack #

Adds a value to the back

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

Parameters

NameTypeDescription
valueHvalue to add

Example

d := Collection.Deque->New()<String>;
d->AddBack("a"); d->AddBack("b");
d->Back()->PrintLine(); # b

AddFront #

Adds a value to the front

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

Parameters

NameTypeDescription
valueHvalue to add

Example

d := Collection.Deque->New()<String>;
d->AddBack("b"); d->AddFront("a");
d->Front()->PrintLine(); # a

Back #

Gets the back value without removing it

method : public : Back() ~ H

Return

TypeDescription
Hthe value, or Nil if empty

Example

d := Collection.Deque->New()<String>;
d->AddBack("a"); d->AddBack("b");
d->Back()->PrintLine(); # b

Empty #

Removes all values

method : public : Empty() ~ Nil

Front #

Gets the front value without removing it

method : public : Front() ~ H

Return

TypeDescription
Hthe value, or Nil if empty

Example

d := Collection.Deque->New()<String>;
d->AddBack("a");
d->Front()->PrintLine(); # a

Get #

Gets a value by position, 0 being the front

method : public : Get(index:Int) ~ H

Parameters

NameTypeDescription
indexIntposition

Return

TypeDescription
Hthe value, or Nil for a bad index

Example

d := Collection.Deque->New()<String>;
d->AddBack("a"); d->AddBack("b");
d->Get(1)->PrintLine(); # b

IsEmpty #

Checks for no values

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty

New # constructor

Default constructor

New()

Example

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

RemoveBack #

Removes the back value

method : public : RemoveBack() ~ H

Return

TypeDescription
Hthe value, or Nil if empty

Example

d := Collection.Deque->New()<String>;
d->AddBack("a"); d->AddBack("b");
d->RemoveBack()->PrintLine(); # b

RemoveFront #

Removes the front value

method : public : RemoveFront() ~ H

Return

TypeDescription
Hthe value, or Nil if empty

Example

d := Collection.Deque->New()<String>;
d->AddBack("a"); d->AddBack("b");
d->RemoveFront()->PrintLine(); # a

Set #

Replaces a value by position

method : public : Set(value:H, index:Int) ~ Bool

Parameters

NameTypeDescription
valueHnew value
indexIntposition

Return

TypeDescription
Booltrue if set, false for a bad index

Example

d := Collection.Deque->New()<String>;
d->AddBack("a");
d->Set("z", 0)->PrintLine(); # true

Size #

Gets the number of values

method : public : Size() ~ Int

Return

TypeDescription
Intsize

ToArray #

Copies the values, front first, into an array

method : public : ToArray() ~ H[]

Return

TypeDescription
H[]array of Size() values

Example

d := Collection.Deque->New()<String>;
d->AddBack("b"); d->AddFront("a");
d->ToArray()[0]->PrintLine(); # a