v2026.2.1
All Bundles

HashSet

Hash-based set for O(1) membership testing without storing values

set := Collection.HashSet->New()<IntRef>;
set->Add(IntRef->New(1));
set->Add(IntRef->New(2));
set->Add(IntRef->New(3));

set->Has(IntRef->New(2))->PrintLine(); # true
set->Has(IntRef->New(5))->PrintLine(); # false

set->Remove(IntRef->New(2));
set->Has(IntRef->New(2))->PrintLine(); # false

Operations

Add

Adds a value to the set

method : public : Add(value:H) ~ Bool

Parameters

NameTypeDescription
valueHvalue to add

Return

TypeDescription
Booltrue if added, false if already exists

Empty

Clears the set

method : public : Empty() ~ Nil

Has

Checks if a value exists in the set

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

Parameters

NameTypeDescription
valueHvalue to check

Return

TypeDescription
Booltrue if found, false otherwise

IsEmpty

Checks if set is empty

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty, false otherwise

New

Default constructor

New()

Remove

Removes a value from the set

method : public : Remove(value:H) ~ Bool

Parameters

NameTypeDescription
valueHvalue to remove

Return

TypeDescription
Booltrue if removed, false if not found

Size

Size of set

method : public : Size() ~ Int

Return

TypeDescription
Intnumber of elements

ToArray

Gets all values as an array

method : public : ToArray() ~ H[]

Return

TypeDescription
H[]array of values

ToString

Formats the set into a string

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation

ToVector

Gets all values as a vector

method : public : ToVector() ~ Vector<H>

Return

TypeDescription
Vector<H>vector of values