A set that returns the closest element to a query.
When looking up a value, returns the element in the set that is closest to the query. For numeric keys, distance is |query - element|.
Tie-breaking: When two elements are equidistant, use :< to prefer the smaller element, or :> to prefer the larger element.
A set that returns the closest element to a query. When looking up a value, returns the element in the set that is closest to the query. For numeric keys, distance is |query - element|. Tie-breaking: When two elements are equidistant, use :< to prefer the smaller element, or :> to prefer the larger element.
(find-nearest root query cmp distance-fn tiebreak)Find the nearest element to query in the tree.
Parameters:
Returns the nearest element, or nil if tree is empty.
Find the nearest element to query in the tree. Parameters: - root: the tree root - query: the value to find nearest to - cmp: comparator for ordering - distance-fn: (fn [a b] -> number) returns distance between elements - tiebreak: :< (prefer smaller) or :> (prefer larger) when equidistant Returns the nearest element, or nil if tree is empty.
(numeric-distance a b)Default distance function for numeric types.
Default distance function for numeric types.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |