[−][src]Trait acap::NearestNeighbors
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>,
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
Search for nearest neighbors and add them to a neighborhood.
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>,
&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>,
&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
.
Implementors
impl<K, V> NearestNeighbors<K, V> for FlatKdTree<V> where
K: KdProximity<V>,
V: Coordinates,
[src]
K: KdProximity<V>,
V: Coordinates,
fn search<'k, 'v, N>(&'v self, neighborhood: N) -> N where
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
[src]
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
impl<K, V> NearestNeighbors<K, V> for KdTree<V> where
K: KdProximity<V>,
V: Coordinates,
[src]
K: KdProximity<V>,
V: Coordinates,
fn search<'k, 'v, N>(&'v self, neighborhood: N) -> N where
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
[src]
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
impl<K, V> NearestNeighbors<K, V> for FlatVpTree<V> where
K: Proximity<V, Distance = V::Distance>,
V: Proximity,
[src]
K: Proximity<V, Distance = V::Distance>,
V: Proximity,
fn search<'k, 'v, N>(&'v self, neighborhood: N) -> N where
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
[src]
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
impl<K, V> NearestNeighbors<K, V> for VpTree<V> where
K: Proximity<V, Distance = V::Distance>,
V: Proximity,
[src]
K: Proximity<V, Distance = V::Distance>,
V: Proximity,
fn search<'k, 'v, N>(&'v self, neighborhood: N) -> N where
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
[src]
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
impl<K: Proximity<V>, V> NearestNeighbors<K, V> for ExhaustiveSearch<V>
[src]
fn search<'k, 'v, N>(&'v self, neighborhood: N) -> N where
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,
[src]
K: 'k,
V: 'v,
N: Neighborhood<&'k K, &'v V>,