Set
Ordered set of generic objects
# 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
GetKeys
Get a collection of keys
method : public : GetKeys() ~ Vector<K>
Return
Type | Description |
---|---|
Vector<K> | vector of keys |
Has
Checks for key in set
method : public : Has(key:K) ~ Bool
Parameters
Name | Type | Description |
---|---|---|
key | K | search key |
Return
Type | Description |
---|---|
Bool | true if found, false otherwise |
Insert
Inserts a key into the set
method : public : Insert(key:K) ~ Nil
Parameters
Name | Type | Description |
---|---|---|
key | K | key |
IsEmpty
Checks to see if the set is empty
method : public : IsEmpty() ~ Bool
Return
Type | Description |
---|---|
Bool | true if empty, false otherwise |
Remove
Removes a key from the set
method : public : Remove(key:K) ~ Bool
Parameters
Name | Type | Description |
---|---|---|
key | K | key for value to remove |
Return
Type | Description |
---|---|
Bool | true if removed, false otherwise |
ToString
Formats the collection into a string. If an element implements the 'Stringify' interface, it's 'ToString()' is called.
method : public : ToString() ~ String
Return
Type | Description |
---|---|
String | string representation |