SortedMap¶
Import: import system.collections;
Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.
SortedMap¶
An ordered map backed by parallel sorted arrays (binary search + shift on insert/remove). O(log n) lookup, O(n) insert/remove, ascending-key iteration. Prefer Map<K, V> when key order doesn't matter — it has O(1) average insert/lookup.
constructor¶
Allocates an empty sorted map with an initial capacity (defaults to 8).
length¶
Number of key/value pairs currently stored.
is_empty¶
True when the map is empty.
clear¶
Removes every entry, keeping capacity. Live slots are overwritten with a zero value so reference keys/values release immediately.
this¶
Inserts or updates the value for a key. O(log n) to locate, O(n) worst case to shift.
get¶
Value for key, or None when the key is absent.
this¶
Value for key. Panics when the key is absent — this is what sm[k] compiles to; use get(k) for absence-tolerant reads.
contains¶
True if the map contains the key.
remove¶
Removes a key and returns true if it was present.
first_key¶
The smallest key, or None when empty.
last_key¶
The largest key, or None when empty.
ceiling_key¶
The smallest key >= key, or None if every key is smaller.
floor_key¶
The largest key <= key, or None if every key is larger.
keys¶
Returns a new list of the keys in ascending order.
values¶
Returns a new list of the values, ordered by ascending key.
iterator¶
Gets an iterator over entries in ascending key order.