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

Thread-safe balanced binary tree map.

SortedMapSync<K, V> exposes the same typed API as SortedMap<K, V> while the native runtime serializes operations on the instance storage. Keys stay typed as K and values stay typed as V throughout the public API.

Prefer SortedMap<K, V> for single-threaded hot paths. Use this class when shared mutable access from several threads is required.

Example
import klyn.collections

values = ts:{3: "three", 1: "one", 2: "two"}
assert values.keys() == i:[1, 2, 3]
Properties
Modifier and Type Member Description
public readonly native property size
size as ULong
Gets the number of entries stored in the map.
Inherited Properties
propertyInherited Properties from Object: type
propertyInherited Properties from Map: size
Constructors
Modifier and Type Member Description
public SortedMapSync Creates an empty synchronized map.
public SortedMapSync
SortedMapSync(keys as IList<K>, values as IList<V>):
Creates a synchronized map from key-value pairs.
public SortedMapSync
SortedMapSync(map as Map<K, V>):
Creates a synchronized map from another map.
Methods
Modifier and Type Member Description
public native clear
clear() as Void
Clears all entries.
public native containsValue
containsValue(value as V) as Boolean
Returns true if the value exists.
public get
get<R>(key as K, defaultValue as R) as R:
Returns the value associated with the key, or the provided default value when the key is absent.
public native items
items() as IList<Tuple<K, V> >
Returns key-value tuples in ascending key order.
public native keys
keys() as IList<K>
Returns the keys in ascending order.
public native remove
remove(key as K) as Boolean
Removes an entry.
public native override toString
toString() as String
Returns the ts:{...} representation of this synchronized sorted map.
public native values
values() as IList<V>
Returns the values in ascending key order.
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 the key.
Inherited Operators
operatorInherited Operators from Map: operator in(key as K) as Boolean, operator[](key as K) as V