A Set is a collection of objects where order is not important and every object can occur only once.
Charta supports the collection Set which can be used to store a collection of objects when the order of the objects is not important. However, the Set does support access to its members through an integral index. This facilitates the display of large sets by allowing access to a subset of its members at defined locations.
Also, a Set can be used in a for each statement.
Supported operations
The following operations are supported by a Set:
| Operation | Description |
|---|---|
| Add | Adds a value to the set if it is not already present. |
| Remove | Removes a value from the set if it is present. |
| Size | Retrieves the current amount of elements in the set |
| Index of | Returns the index of a value in the set. Returns -1 if the value is not present. |
| Contains | Returns a Boolean value indicating whether the specified value is present in the set. |
| For each | A set can be used in a for each statement to iterate over all its members. |
| [] | Set members at specific integral indexes can be retrieved using the [] operator. |