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
Name | Description |
---|---|
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
Name | Description |
---|---|
DistanceFunction | Returns The distance between its arguments, in a [0 ; Number.POSITIVE_INFINITY ] range |
ProximityMap | 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 |
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.
findNearestKeyMatch
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
Name | Description |
---|---|
K | |
V |
Parameters
Name | Type | Description |
---|---|---|
distanceFunction | DistanceFunction<K> | Returns the distance between two keys |
key | K | The key used as a reference to find the closest key |
entries | Iterable<readonly [K, V]> |
Constants
Name | Description |
---|---|
ProximityMap | undocumented |