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

Thread-safe hash map implementation.

HashMapSync<K, V> exposes the same typed API as HashMap<K, V> and uses the hash-backed native runtime path with synchronized instance storage. Average add, lookup and remove remain O(1), with the expected lock overhead for shared mutable access. Iteration follows the hash table's internal bucket traversal and has no insertion-order guarantee.

Example
values = s:{"answer": 42}
assert values is HashMapSync<String, Int>
Properties
Modifier and Type Member Description
public readonly native property size
size as ULong
Gets the number of entries stored in this synchronized hash map.
Inherited Properties
propertyInherited Properties from Object: type
propertyInherited Properties from Map: size
Constructors
Modifier and Type Member Description
public HashMapSync Creates an empty synchronized hash map.
public HashMapSync
HashMapSync(keys as IList<K>, values as IList<V>):
Creates a synchronized hash map from key-value pairs.
public HashMapSync
HashMapSync(map as Map<K, V>):
Creates a synchronized hash map 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 s:{...} 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 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