Skip to main content

package @rimbu/proximity

The @rimbu/proximity package provides implementations of ProximityMap.

See the Rimbu docs Map page for more information. This is a convenience package that exports everything from the following sub-packages:

Interfaces

NameDescription
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

Namespaces

NameDescription
DistanceFunctionReturns The distance between its arguments, in a [0; Number.POSITIVE_INFINITY] range
ProximityMapA 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

Functions

findNearestKeyMatch

Given an Iterable of [key, value] entries, applies the distance function to each key, finding the one closest to the input key, also returning its associated value as well as the related distance; returns undefined only when there are no successful match - that is, all the keys have +inf distance. Performs a full linear scan unless a distance equal to 0 is encountered, in which case the function returns immediately; otherwise, the algorithm selects the smallest non-infinite distance: if multiple keys happen to have such distance, the selection order is not guaranteed.

Definition

export declare function findNearestKeyMatch<K, V>(distanceFunction: DistanceFunction<K>, key: K, entries: Iterable<readonly [K, V]>): NearestKeyMatch<K, V> | undefined;

Type parameters
NameDescription
K
V

Parameters

NameTypeDescription
distanceFunctionDistanceFunction<K>Returns the distance between two keys
keyKThe key used as a reference to find the closest key
entriesIterable<readonly [K, V]>

Constants

NameDescription
ProximityMapundocumented