public class HashMap<K, V> extends Object implements Map<K, V>:
Hash map implementation.
HashMap<K, V> implements Map<K, V> directly. It is independent from the ordered SortedMap<K, V> implementation and uses native hash storage for average O(1) insertion, lookup and removal. Iteration follows the hash table's internal bucket traversal and therefore has no insertion-order guarantee.
values = {"answer": 42}
assert values is HashMap<String, Int>| Modifier and Type | Member | Description |
|---|---|---|
| public readonly native property | sizesize as ULong |
Gets the number of entries stored in this hash map. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | HashMapHashMap(): |
Creates an empty hash map. |
| public | HashMap | Creates a new HashMap from key-value pairs. |
| public | HashMap | Creates a new HashMap from another map. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | clearclear() as Void |
Removes every entry. |
| public native | containsValuecontainsValue(value as V) as Boolean |
Returns true if an entry contains the requested 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 as a list. |
| public native | keyskeys() as IList<K> |
Returns the keys as a list. |
| public native | removeremove(key as K) as Boolean |
Removes an entry. |
| public native override | toStringtoString() as String |
Returns the {...} representation of the entries. |
| public native | valuesvalues() as IList<V> |
Returns the values as a list. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | operator in(key as K) as Boolean | Returns true if the key exists. |
| public native static | operator!=(readonly notnull left as HashMap, readonly notnull right as HashMap) as Boolean | Compares two hash maps structurally for inequality. |
| public native static | operator==(readonly notnull left as HashMap, readonly notnull right as HashMap) as Boolean | Compares two hash maps structurally. |
| public native | operator[](key as K) as V | Gets or sets the value associated with a key. |