Trait space::KnnMap[][src]

pub trait KnnMap: KnnPoints {
    type Value;
    fn get_value(&self, index: Self::Ix) -> &Self::Value;

    fn knn_values(
        &self,
        query: &Self::Point,
        num: usize
    ) -> Vec<(Neighbor<<Self::Metric as Metric<Self::Point>>::Unit, Self::Ix>, &Self::Value)> { ... }
fn nn_value(
        &self,
        query: &Self::Point
    ) -> Option<(Neighbor<<Self::Metric as Metric<Self::Point>>::Unit, Self::Ix>, &Self::Value)> { ... }
fn knn_keys_values(
        &self,
        query: &Self::Point,
        num: usize
    ) -> Vec<(Neighbor<<Self::Metric as Metric<Self::Point>>::Unit, Self::Ix>, &Self::Point, &Self::Value)> { ... }
fn nn_key_value(
        &self,
        query: &Self::Point
    ) -> Option<(Neighbor<<Self::Metric as Metric<Self::Point>>::Unit, Self::Ix>, &Self::Point, &Self::Value)> { ... } }
Expand description

This trait gives knn search collections the ability to give the nearest neighbor values back.

This is not the final API. Eventually, the iterator type will be chosen by the collection, but for now it is a Vec until Rust stabilizes GATs.

Associated Types

Required methods

Get a value using a neighbor index returned by Knn::knn or Knn::nn.

This should only be used directly after one of the mentioned methods are called to retrieve a value associated with a neighbor, and will panic if the index is incorrect due to mutating the data structure thereafter. The index is only valid up until the next mutation.

Provided methods

Get num nearest neighbor keys of target.

For many KNN search algorithms, the returned neighbors are approximate, and may not be the actual nearest neighbors.

Get the nearest neighbor key of target.

For many KNN search algorithms, the returned neighbors are approximate, and may not be the actual nearest neighbors.

Get num nearest neighbor keys of target.

For many KNN search algorithms, the returned neighbors are approximate, and may not be the actual nearest neighbors.

Get the nearest neighbor key of target.

For many KNN search algorithms, the returned neighbors are approximate, and may not be the actual nearest neighbors.

Implementors