v2026.11.2
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.

FloatVector

Growable array of Float values; nothing is boxed

Example

v := Collection.FloatVector->New();
v->AddBack(2.5); v->AddBack(0.5);
v->Sort();
v->Get(0)->PrintLine();   # 0.5
v->Sum()->PrintLine();    # 3

Operations

AddBack # native

Adds a value to the end

method : public : native : AddBack(value:Float) ~ Nil

Parameters

NameTypeDescription
valueFloatvalue

Example

v := Collection.FloatVector->New();
v->AddBack(4.25);
v->Get(0)->PrintLine(); # 4.25

Clear #

Removes every value; the reserved room is kept

method : public : Clear() ~ Nil

Example

v := Collection.FloatVector->New([1.5]);
v->Clear();
v->Size()->PrintLine(); # 0

Each #

Calls a function for each value

method : public : Each(f:(Float)~Nil) ~ FloatVector

Parameters

NameTypeDescription
f(Float)~Nilfunction called

Return

TypeDescription
FloatVectorthis vector

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->Each(\(f) => { f->PrintLine(); });

Empty #

Removes every value; the same as Clear

method : public : Empty() ~ Nil

Example

v := Collection.FloatVector->New([1.5]);
v->Empty();
v->IsEmpty()->PrintLine(); # true

Find # native

Finds the first index of a value (exact comparison)

method : public : native : Find(value:Float) ~ Int

Parameters

NameTypeDescription
valueFloatvalue to find

Return

TypeDescription
Intindex, or -1 if not found

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->Find(2.5)->PrintLine(); # 1

First #

Gets the first value

method : public : First() ~ Float

Return

TypeDescription
Floatfirst value, or 0.0 if empty

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->First()->PrintLine(); # 1.5

Get # native

Gets an indexed value

method : public : native : Get(index:Int) ~ Float

Parameters

NameTypeDescription
indexIntindex

Return

TypeDescription
Floatvalue, or 0.0 if the index is out of range

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->Get(1)->PrintLine(); # 2.5

Has #

Checks for a value (exact comparison)

method : public : Has(value:Float) ~ Bool

Parameters

NameTypeDescription
valueFloatvalue to find

Return

TypeDescription
Booltrue if found, false otherwise

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->Has(1.5)->PrintLine(); # true

IsEmpty #

Checks to see if the vector is empty

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty, false otherwise

Example

v := Collection.FloatVector->New();
v->IsEmpty()->PrintLine(); # true

Last #

Gets the last value

method : public : Last() ~ Float

Return

TypeDescription
Floatlast value, or 0.0 if empty

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->Last()->PrintLine(); # 2.5

New # constructor

Default constructor

New()

Example

v := Collection.FloatVector->New();
v->AddBack(1.5);
v->Size()->PrintLine(); # 1

New # constructor

Constructor that reserves room for a number of values

New(capacity:Int)

Parameters

NameTypeDescription
capacityIntnumber of values to reserve

Example

v := Collection.FloatVector->New(1000);
v->Size()->PrintLine(); # 0

New # constructor

Copy constructor

New(values:Float[])

Parameters

NameTypeDescription
valuesFloatvalues to copy

Example

v := Collection.FloatVector->New([1.0, 2.0]);
v->Get(1)->PrintLine(); # 2

Remove #

Removes an indexed value, shifting the later values down

method : public : Remove(index:Int) ~ Float

Parameters

NameTypeDescription
indexIntindex

Return

TypeDescription
Floatremoved value, or 0.0 if the index is out of range

Example

v := Collection.FloatVector->New([1.5, 2.5, 3.5]);
v->Remove(0)->PrintLine(); # 1.5

RemoveBack #

Removes the last value

method : public : RemoveBack() ~ Float

Return

TypeDescription
Floatremoved value, or 0.0 if empty

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->RemoveBack()->PrintLine(); # 2.5

Reserve #

Reserves room for at least a number of values

method : public : Reserve(capacity:Int) ~ Nil

Parameters

NameTypeDescription
capacityIntnumber of values

Example

v := Collection.FloatVector->New();
v->Reserve(1000000);
v->Size()->PrintLine(); # 0

Set # native

Sets an indexed value

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

Parameters

NameTypeDescription
valueFloatvalue
indexIntindex

Return

TypeDescription
Booltrue if set, false if the index is out of range

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->Set(9.0, 0)->PrintLine(); # true

Size #

Size of vector

method : public : Size() ~ Int

Return

TypeDescription
Intnumber of values

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->Size()->PrintLine(); # 2

Sort #

Sorts the values in ascending order (a stable merge sort, O(n log n))

method : public : Sort() ~ Nil

Example

v := Collection.FloatVector->New([3.0, -1.0, 2.0]);
v->Sort();
v->First()->PrintLine(); # -1

Sum # native

Sums the values

method : public : native : Sum() ~ Float

Return

TypeDescription
Floatsum

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->Sum()->PrintLine(); # 4

ToArray #

Copies the values into an array

method : public : ToArray() ~ Float[]

Return

TypeDescription
Floatarray of values

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->ToArray()->Size()->PrintLine(); # 2

ToString #

Formats the vector into a string

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation

Example

v := Collection.FloatVector->New([1.5, 2.5]);
v->ToString()->PrintLine(); # [1.5,2.5]