SplitScript reference / Map<K, V>

Map<K, V>

type constructor

Map<K where Equatable, V>

Stores an insertion-ordered association from unique keys to values.

Keys are compared with Equatable. The representation is tuned for the small and medium lookup tables common in autosplitters; no complexity guarantee is part of the API. The map retains its identity and contents across ticks, so aliases observe every mutation. Indexing returns the stored value and traps when the key is absent; use Map.containsKey first when absence is expected. This keeps maps whose values are themselves optional unambiguous without adding another lookup operation. Maps support equality when both keys and values are equatable; it compares key-value pairs independently of insertion order. Such maps can themselves be set elements or map keys.

In Unity schemas, maps describe managed dictionaries. Both keys and values must support ManagedReadable. Reads produce owned, deeply immutable maps, sharing the root's budgets with nested strings, arrays, lists, and snapshots. If distinct game keys decode to equal local keys, the whole read fails. Recursive duplicate comparisons share the read's work budget; exhaustion fails the read and leaves the previous state value intact.

Examples

Store and read route metadata

let routes = Map.new<String, u32>()
routes["Atrium"] = 12
if routes.containsKey("Atrium") {
    print(routes["Atrium"])
}

Methods

MemberDescriptionAvailable through
clearRemoves every entry while preserving this map's identity.
containsKeyReports whether an equal key is present.
insertInserts a key-value pair or replaces the value for an existing key.
isEmptyReports whether this map contains no entries.
iteratorCreates an insertion-order cursor over this map's entries.
lengthReturns the number of stored key-value pairs.
newCreates an empty map.
removeRemoves the entry for a key when present.