SplitScript reference / Set<T>
Set<T>
type constructor
Set<T where Equatable>
Stores a growable collection of unique values for one script instance.
A set keeps its allocation and contents across ticks. Mutating operations update the same set value, so a global set can track visited checkpoints without rebuilding a collection on every update. Equality compares complete element values independently of insertion order. Sets can themselves be set elements or map keys, including recursively nested collections.
In Unity schemas, sets describe managed hash sets. Elements must support ManagedReadable and local equality. Reads recursively create owned, deeply immutable values and share their root's budgets. Distinct game elements that decode to equal local values make the whole read fail. Recursive duplicate comparisons share the read's work budget; exhaustion fails the read and leaves the previous state value intact.
Examples
Track visited rooms
let visited = Set.new<String>()
visited.insert("Atrium")
Methods
| Member | Description | Available through |
|---|---|---|
| clear | Removes every stored value while retaining the set itself. | |
| contains | Reports whether an equal value is present. | |
| insert | Inserts a value if it is not already present. | |
| isEmpty | Reports whether the set contains no values. | |
| iterator | Creates an independent cursor over this set. | |
| length | Returns the number of stored values. | |
| new | Creates an empty set. | |
| remove | Removes an equal value if it is present. |