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.

SetHash

Unordered set of generic objects

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

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

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

Operations

Empty #

Clears the set

method : public : Empty() ~ Nil

Example

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

GetKeys #

Get a collection of keys

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

Return

TypeDescription
Vector<K>vector of keys

Example

sh := Collection.SetHash->New()<String>;
sh->Insert("x"); sh->Insert("y");
keys := sh->GetKeys()<String>;
keys->Size()->PrintLine(); # 2

Has #

Checks for key in set

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

Parameters

NameTypeDescription
keyKsearch key

Return

TypeDescription
Booltrue if found, false otherwise

Example

sh := Collection.SetHash->New()<String>;
sh->Insert("present");
sh->Has("present")->PrintLine();  # true
sh->Has("absent")->PrintLine();   # false

Insert #

Inserts a key into the set

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

Parameters

NameTypeDescription
keyKkey

Example

sh := Collection.SetHash->New()<String>;
sh->Insert("blue");
sh->Has("blue")->PrintLine(); # true

IsEmpty #

Checks to see if the set is empty

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty, false otherwise

Example

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

New # constructor

Default constructor

New()

Example

sh := Collection.SetHash->New()<String>;
sh->Insert("hello");
sh->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

sh := Collection.SetHash->New()<String>;
sh->Insert("tmp");
sh->Remove("tmp")->PrintLine(); # true
sh->Has("tmp")->PrintLine();    # false

Size #

Size of set

method : public : Size() ~ Int

Return

TypeDescription
Intnumber of elements

Example

sh := Collection.SetHash->New()<String>;
sh->Insert("a"); sh->Insert("b");
sh->Size()->PrintLine(); # 2

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

sh := Collection.SetHash->New()<String>;
sh->Insert("m"); sh->Insert("n");
sh->ToString()->PrintLine();