HashMap
classin packageklyn.collections
public class HashMap<K, V> extends Object implements Map<K, V>:
└ HashMap
All Implemented Interfaces: Map

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.

Example
values = {"answer": 42}
assert values is HashMap<String, Int>
Properties
Modifier and Type Member Description
public readonly native property size
size as ULong
Gets the number of entries stored in this hash map.
Inherited Properties
propertyInherited Properties from Object: type
propertyInherited Properties from Map: size
Constructors
Modifier and Type Member Description
public HashMap Creates an empty hash map.
public HashMap
HashMap(keys as IList<K>, values as IList<V>):
Creates a new HashMap from key-value pairs.
public HashMap
HashMap(map as Map<K, V>):
Creates a new HashMap from another map.
Methods
Modifier and Type Member Description
public native clear
clear() as Void
Removes every entry.
public native containsValue
containsValue(value as V) as Boolean
Returns true if an entry contains the requested value.
public get
get<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
items() as IList<Tuple<K, V> >
Returns key-value tuples as a list.
public native keys
keys() as IList<K>
Returns the keys as a list.
public native remove
remove(key as K) as Boolean
Removes an entry.
public native override toString
toString() as String
Returns the {...} representation of the entries.
public native values
values() as IList<V>
Returns the values as a list.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toString, toXml
methodInherited Methods from Map: clear, containsValue, get, items, keys, remove, values
Operators
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.
Inherited Operators
operatorInherited Operators from Map: operator in(key as K) as Boolean, operator[](key as K) as V