[][src]Trait acap::Neighborhood

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; }

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

fn target(&self) -> K

Returns the target of the nearest neighbor search.

fn contains<D>(&self, distance: D) -> bool where
    D: PartialOrd<K::Distance>, 

Check whether a distance is within the current search radius.

fn consider(&mut self, item: V) -> K::Distance

Consider a new candidate neighbor.

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

Loading content...

Implementors

Loading content...