Skip to main content

interface OrderedMap<K,V>

A type-invariant immutable Ordered Map of key type K, and value type V. In the Map, each key has exactly one value, and the Map cannot contain duplicate keys. See the Map documentation and the OrderedMap API documentation

Companion namespace: OrderedMap

Implemented by: OrderedMap.NonEmpty<K,V>

Type parameters

NameDescription
Kthe key type
Vthe value type
note
  • The OrderedMap keeps maintains the insertion order of elements, thus iterators and streams will also reflect this order. - The OrderedMap wraps around a Map instance, thus has mostly the same time complexity as the contained Map. - The OrderedMap keeps the key insertion order in a List, thus its space complexity is higher than a regular Map.
example
const m1 = OrderedHashMap.empty<number, string>()
const m2 = OrderedHashMap.of([1, 'a'], [2, 'b'])