nearest method

  1. @override
V nearest(
  1. V object, {
  2. TreeSearch nearestOption = TreeSearch.NEAREST,
})
override

Search the tree for the matching object or the nearestOption if missing. See TreeSearch.

Implementation

@override
V nearest(V object, {TreeSearch nearestOption = TreeSearch.NEAREST}) {
  AvlNode<V>? found = _searchNearest(object, option: nearestOption);
  if (found != null) {
    return found.object;
  }
  throw StateError('No nearest element');
}