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.

IntSet

Hash set of Int values: open addressing over plain arrays, so nothing is boxed. Every Int is a valid member, including 0 and the Int64 extremes.

Example

set := Collection.IntSet->New();
set->Add(5)->PrintLine();   # true
set->Add(5)->PrintLine();   # false
set->Has(5)->PrintLine();   # true
set->Size()->PrintLine();   # 1

Operations

Add # native

Adds a value

method : public : native : Add(value:Int) ~ Bool

Parameters

NameTypeDescription
valueIntvalue

Return

TypeDescription
Booltrue if added, false if it was already in the set

Example

set := Collection.IntSet->New();
set->Add(-1)->PrintLine(); # true

Each #

Calls a function for each value. The function must not change the set.

method : public : Each(f:(Int)~Nil) ~ IntSet

Parameters

NameTypeDescription
f(Int)~Nilfunction called

Return

TypeDescription
IntSetthis set

Example

set := Collection.IntSet->New();
set->Add(1);
set->Each(\(v) => { v->PrintLine(); });

Empty #

Removes every value

method : public : Empty() ~ Nil

Example

set := Collection.IntSet->New();
set->Add(1);
set->Empty();
set->Size()->PrintLine(); # 0

Has # native

Checks for a value

method : public : native : Has(value:Int) ~ Bool

Parameters

NameTypeDescription
valueIntvalue

Return

TypeDescription
Booltrue if found, false otherwise

Example

set := Collection.IntSet->New();
set->Add(3);
set->Has(3)->PrintLine(); # true

Insert #

Inserts a value; the same as Add, for the method name the other sets use

method : public : Insert(value:Int) ~ Nil

Parameters

NameTypeDescription
valueIntvalue

Example

set := Collection.IntSet->New();
set->Insert(9);
set->Has(9)->PrintLine(); # true

IsEmpty #

Checks to see if the set is empty

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty, false otherwise

Example

set := Collection.IntSet->New();
set->IsEmpty()->PrintLine(); # true

New # constructor

Default constructor

New()

Example

set := Collection.IntSet->New();
set->Insert(1);
set->Size()->PrintLine(); # 1

New # constructor

Constructor that reserves room for a number of values

New(capacity:Int)

Parameters

NameTypeDescription
capacityIntnumber of values expected

Example

set := Collection.IntSet->New(100000);
set->Size()->PrintLine(); # 0

Remove # native

Removes a value

method : public : native : Remove(value:Int) ~ Bool

Parameters

NameTypeDescription
valueIntvalue

Return

TypeDescription
Booltrue if removed, false if it was not in the set

Example

set := Collection.IntSet->New();
set->Add(3);
set->Remove(3)->PrintLine(); # true

Size #

Number of values

method : public : Size() ~ Int

Return

TypeDescription
Intnumber of values

Example

set := Collection.IntSet->New();
set->Add(1); set->Add(2);
set->Size()->PrintLine(); # 2

ToArray # native

Gets the values as an array

method : public : native : ToArray() ~ Int[]

Return

TypeDescription
Intarray of values

Example

set := Collection.IntSet->New();
set->Add(1); set->Add(2);
set->ToArray()->Size()->PrintLine(); # 2

ToString #

Formats the set into a string

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation

Example

set := Collection.IntSet->New();
set->Add(1);
set->ToString()->PrintLine(); # {1}