SplitScript reference / Set
Set
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.
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. |