Trait acap::knn::Neighborhood[][src]

pub trait Neighborhood<K: Proximity<V>, V> {
    fn target(&self) -> K;
fn contains<D>(&self, distance: D) -> bool
    where
        D: PartialOrd<K::Distance>
;
fn consider(&mut self, item: V) -> K::Distance; }
Expand description

Accumulates nearest neighbor search results.

Type parameters:

  • K: The type of the search target (the “key” type)
  • V: The type of neighbors this contains (the “value” type)

Neighborhood implementations keep track of the current search radius and accumulate the results, work which would otherwise have to be duplicated for every nearest neighbor search algorithm. They also serve as a customization point, allowing for functionality to be injected into any NearestNeighbors implementation (for example, filtering the result set or limiting the number of neighbors considered).

Required methods

Returns the target of the nearest neighbor search.

Check whether a distance is within the current search radius.

Consider a new candidate neighbor.

Returns self.target().distance(item).

Implementors