interface OrderedSortedMap<K,V>
A type-invariant immutable Ordered SortedMap 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 OrderedSortedMap API documentation
Companion namespace: OrderedSortedMap
Extends: OrderedMapBase<K,V,Tp>
Implemented by: OrderedSortedMap.NonEmpty<K,V>
Type parameters
Name | Description |
---|---|
K | the key type |
V | the value type |
note
- The OrderedSortedMap keeps maintains the insertion order of elements, thus iterators and streams will also reflect this order. - The OrderedSortedMap wraps around a SortedMap instance, thus has mostly the same time complexity as the SortedMap. - The OrderedSortedMap keeps the key insertion order in a List, thus its space complexity is higher than a regular SortedMap.
example
const m1 = OrderedSortedMap.empty<number, string>()
const m2 = OrderedSortedMap.of([1, 'a'], [2, 'b'])
Properties
keyOrder
Returns a List
instance containing the key order of the Map.
keyOrder
List
instance containing the key order of the Map.sourceMap
Returns the contained Map
instance.
sourceMap
Map
instance.Definition
readonly sourceMap:
WithKeyValue
<Tp, K, V>['sourceMap'];
example
const m = OrderedHashMap.of([2, 'b'], [1, 'a'])
console.log(m.sourceMap.toString())
// => HashMap(1 -> 'a', 2 -> 'b')