public interface Map<K, V>:
Common contract for associative collections.
Map<K, V> does not prescribe a storage strategy and cannot be instantiated. The unprefixed literal {...} creates a HashMap, while t:{...} creates a SortedMap. Synchronized variants use s:{...} and ts:{...} respectively.
import klyn.collections
values as Map<String, Int> = {"answer": 42}
assert values["answer"] == 42| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | sizesize as ULong |
Gets the number of entries in the map. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | clearclear() as Void |
Removes every entry from the map. |
| public | 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 value associated with a key, or a typed default value when the key is absent. |
| public | items | Returns key-value tuples in the implementation's traversal order. |
| public | keyskeys() as IList<K> |
Returns the keys as a list in the implementation's traversal order. |
| public | removeremove(key as K) as Boolean |
Removes an entry. |
| public | valuesvalues() as IList<V> |
Returns the values as a list in the implementation's traversal order. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | operator in(key as K) as Boolean | Returns whether the map contains a key. |
| public | operator[](key as K) as V | Gets or sets the value associated with a key. |