import { findNearestKeyMatch } from "https://deno.land/x/rimbu@1.1.0/proximity/common/keyMatching.ts";
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.
Parameters
Returns the distance between two keys
The key used as a reference to find the closest key
Returns
A NearestKeyMatch
object if a closest key -
having a finite distance - exists; undefined
otherwise