public class SortedMap<K, V> extends Object implements Map<K, V>:
Mutable map that traverses entries in ascending key order.
The runtime uses a balanced binary search tree, giving logarithmic lookup, insertion and removal. Use the t:{...} literal when the ordering guarantee is required; prefer HashMap for average constant-time key access.
Native operator mapping:
operator[] is mapped to klyn_collections_Map_operator_index.operator== is mapped to klyn_collections_Map_operator_eq.operator!= is mapped to klyn_collections_Map_operator_ne.import klyn.collections
values = t:{3: "three", 1: "one", 2: "two"}
assert values.keys() == i:[1, 2, 3]| Modifier and Type | Member | Description |
|---|---|---|
| public readonly native property | sizesize as ULong |
Gets the number of entries. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | SortedMapSortedMap(): |
Creates an empty sorted map. |
| public | SortedMap | Creates a sorted map from corresponding key and value lists. |
| public | SortedMap | Creates a sorted map containing another map's entries. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | clearclear() as Void |
Removes every entry. |
| public native | containsValuecontainsValue(value as V) as Boolean |
Returns whether the map contains a value. |
| public | getget<R>(key as K, defaultValue as R) as R: |
Returns the associated value or a typed default when the key is absent. |
| public native | items | Returns key-value tuples in ascending key order. |
| public native | keyskeys() as IList<K> |
Returns keys in ascending order. |
| public native | removeremove(key as K) as Boolean |
Removes an entry. |
| public native override | toStringtoString() as String |
Returns the t:{...} representation of the sorted map. |
| public native | valuesvalues() as IList<V> |
Returns values in ascending key order. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | operator in(key as K) as Boolean | Returns whether the map contains a key. |
| public native static | operator!=(readonly notnull left as SortedMap, readonly notnull right as SortedMap) as Boolean | Compares two sorted maps structurally for inequality. |
| public native static | operator==(readonly notnull left as SortedMap, readonly notnull right as SortedMap) as Boolean | Compares two sorted maps structurally. |
| public native | operator[](key as K) as V | Gets or sets the value associated with a key. |