[][src]Trait acap::NearestNeighbors

pub trait NearestNeighbors<K: Proximity<V>, V = K> {
    fn search<'k, 'v, N>(&'v self, neighborhood: N) -> N
    where
        K: 'k,
        V: 'v,
        N: Neighborhood<&'k K, &'v V>
; fn nearest(&self, target: &K) -> Option<Neighbor<&V, K::Distance>> { ... }
fn nearest_within<D>(
        &self,
        target: &K,
        threshold: D
    ) -> Option<Neighbor<&V, K::Distance>>
    where
        D: TryInto<K::Distance>
, { ... }
fn k_nearest(&self, target: &K, k: usize) -> Vec<Neighbor<&V, K::Distance>> { ... }
fn k_nearest_within<D>(
        &self,
        target: &K,
        k: usize,
        threshold: D
    ) -> Vec<Neighbor<&V, K::Distance>>
    where
        D: TryInto<K::Distance>
, { ... } }

A nearest neighbor search index.

Type parameters:

  • K: The type of the search target (the "key" type)
  • V: The type of the returned neighbors (the "value" type)

In general, exact nearest neighbor searches may be prohibitively expensive due to the curse of dimensionality. Therefore, NearestNeighbor implementations are allowed to give approximate results. The marker trait ExactNeighbors denotes implementations which are guaranteed to give exact results.

Required methods

fn search<'k, 'v, N>(&'v self, neighborhood: N) -> N where
    K: 'k,
    V: 'v,
    N: Neighborhood<&'k K, &'v V>, 

Search for nearest neighbors and add them to a neighborhood.

Loading content...

Provided methods

fn nearest(&self, target: &K) -> Option<Neighbor<&V, K::Distance>>

Returns the nearest neighbor to target (or None if this index is empty).

fn nearest_within<D>(
    &self,
    target: &K,
    threshold: D
) -> Option<Neighbor<&V, K::Distance>> where
    D: TryInto<K::Distance>, 

Returns the nearest neighbor to target within the distance threshold, if one exists.

fn k_nearest(&self, target: &K, k: usize) -> Vec<Neighbor<&V, K::Distance>>

Returns the up to k nearest neighbors to target.

fn k_nearest_within<D>(
    &self,
    target: &K,
    k: usize,
    threshold: D
) -> Vec<Neighbor<&V, K::Distance>> where
    D: TryInto<K::Distance>, 

Returns the up to k nearest neighbors to target within the distance threshold.

Loading content...

Implementors

impl<K, V> NearestNeighbors<K, V> for FlatKdTree<V> where
    K: KdProximity<V>,
    V: Coordinates
[src]

impl<K, V> NearestNeighbors<K, V> for KdTree<V> where
    K: KdProximity<V>,
    V: Coordinates
[src]

impl<K, V> NearestNeighbors<K, V> for FlatVpTree<V> where
    K: Proximity<V, Distance = V::Distance>,
    V: Proximity
[src]

impl<K, V> NearestNeighbors<K, V> for VpTree<V> where
    K: Proximity<V, Distance = V::Distance>,
    V: Proximity
[src]

impl<K: Proximity<V>, V> NearestNeighbors<K, V> for ExhaustiveSearch<V>[src]

Loading content...