Skip to main content

interface ProximityMap<K,V>

A type-invariant immutable 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 ProximityMap API documentation

Companion namespace: ProximityMap

Implemented by: ProximityMapEmpty<K,V>, ProximityMap.NonEmpty<K,V>

Type parameters

NameDescription
Kthe key type
Vthe value type
note

The get() method is designed to perform a linear scan of all the keys, returning the value associated with the key having the least distance from the input key; however, optimized distance functions can greatly improve efficiency by preventing a full scan.

example
const m1 = ProximityMap.empty<number, string>()
const m2 = ProximityMap.of([1, 'a'], [2, 'b'])