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(); # falseOperations
Add
Adds a value to the set
method : public : Add(value:H) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| value | H | value to add |
Return
| Type | Description |
|---|---|
| Bool | true if added, false if already exists |
Has
Checks if a value exists in the set
method : public : Has(value:H) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| value | H | value to check |
Return
| Type | Description |
|---|---|
| Bool | true if found, false otherwise |
IsEmpty
Checks if set is empty
method : public : IsEmpty() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if empty, false otherwise |
Remove
Removes a value from the set
method : public : Remove(value:H) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| value | H | value to remove |
Return
| Type | Description |
|---|---|
| Bool | true if removed, false if not found |
ToArray
Gets all values as an array
method : public : ToArray() ~ H[]Return
| Type | Description |
|---|---|
| H[] | array of values |
ToString
Formats the set into a string
method : public : ToString() ~ StringReturn
| Type | Description |
|---|---|
| String | string representation |
ToVector
Gets all values as a vector
method : public : ToVector() ~ Vector<H>Return
| Type | Description |
|---|---|
| Vector<H> | vector of values |