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

Set

Ordered set of generic objects

Example

# insert elements
set := Collection.Set->New()<String>;
set->Insert("San Francisco");
set->Insert("Oakland");
set->Insert("East Bay");

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

# get value by key
set->Has("Oakland")->PrintLine();

Operations

Empty #

Clears the set

method : public : Empty() ~ Nil

Example

set := Collection.Set->New()<String>;
set->Insert("item");
set->Empty();
set->IsEmpty()->PrintLine(); # true

GetKeys #

Get a collection of keys

method : public : GetKeys() ~ Vector<K>

Return

TypeDescription
Vector<K>vector of keys

Example

set := Collection.Set->New()<String>;
set->Insert("a"); set->Insert("b");
keys := set->GetKeys()<String>;
each(k := keys) { k->PrintLine(); }

Has #

Checks for key in set

method : public : Has(key:K) ~ Bool

Parameters

NameTypeDescription
keyKsearch key

Return

TypeDescription
Booltrue if found, false otherwise

Example

set := Collection.Set->New()<String>;
set->Insert("found");
set->Has("found")->PrintLine();   # true
set->Has("missing")->PrintLine(); # false

Insert #

Inserts a key into the set

method : public : Insert(key:K) ~ Nil

Parameters

NameTypeDescription
keyKkey

Example

set := Collection.Set->New()<String>;
set->Insert("apple");
set->Insert("apple"); # duplicate ignored
set->Size()->PrintLine(); # 1

IsEmpty #

Checks to see if the set is empty

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty, false otherwise

Example

set := Collection.Set->New()<String>;
set->IsEmpty()->PrintLine(); # true
set->Insert("z");
set->IsEmpty()->PrintLine(); # false

New # constructor

Default constructor

New()

Example

set := Collection.Set->New()<String>;
set->Insert("hello");
set->Size()->PrintLine(); # 1

Remove #

Removes a key from the set

method : public : Remove(key:K) ~ Bool

Parameters

NameTypeDescription
keyKkey for value to remove

Return

TypeDescription
Booltrue if removed, false otherwise

Example

set := Collection.Set->New()<String>;
set->Insert("go");
set->Remove("go")->PrintLine();  # true
set->Has("go")->PrintLine();     # false

Size #

Size of map

method : public : Size() ~ Int

Return

TypeDescription
Intsize of queue

Example

set := Collection.Set->New()<String>;
set->Insert("a"); set->Insert("b"); set->Insert("c");
set->Size()->PrintLine(); # 3

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

set := Collection.Set->New()<String>;
set->Insert("x"); set->Insert("y");
set->ToString()->PrintLine(); # [x,y]