Map
interfacein packageklyn.collections
public interface Map<K, V>:
Map

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.

Example
import klyn.collections

values as Map<String, Int> = {"answer": 42}
assert values["answer"] == 42
Properties
Modifier and Type Member Description
public readonly property size
size as ULong
Gets the number of entries in the map.
Methods
Modifier and Type Member Description
public clear
clear() as Void
Removes every entry from the map.
public containsValue
containsValue(value as V) as Boolean
Returns whether the map contains a value.
public get
get<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
items() as IList<Tuple<K, V> >
Returns key-value tuples in the implementation's traversal order.
public keys
keys() as IList<K>
Returns the keys as a list in the implementation's traversal order.
public remove
remove(key as K) as Boolean
Removes an entry.
public values
values() as IList<V>
Returns the values as a list in the implementation's traversal order.
Operators
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.