Trait NearestNeighbour

Source
pub trait NearestNeighbour:
    Debug
    + Send
    + Sync
    + Unpin {
    // Required method
    fn from_batch_with_leaf_size<'a, F: Float, DT: Data<Elem = F>, D: 'a + Distance<F>>(
        &self,
        batch: &'a ArrayBase<DT, Ix2>,
        leaf_size: usize,
        dist_fn: D,
    ) -> Result<Box<dyn Send + Sync + NearestNeighbourIndex<F> + 'a>, BuildError>;

    // Provided method
    fn from_batch<'a, F: Float, DT: Data<Elem = F>, D: 'a + Distance<F>>(
        &self,
        batch: &'a ArrayBase<DT, Ix2>,
        dist_fn: D,
    ) -> Result<Box<dyn Send + Sync + NearestNeighbourIndex<F> + 'a>, BuildError> { ... }
}
Expand description

Nearest neighbour algorithm builds a spatial index structure out of a batch of points. The distance between points is calculated using a provided distance function. The index implements the NearestNeighbourIndex trait and allows for efficient computing of nearest neighbour and range queries.

Required Methods§

Source

fn from_batch_with_leaf_size<'a, F: Float, DT: Data<Elem = F>, D: 'a + Distance<F>>( &self, batch: &'a ArrayBase<DT, Ix2>, leaf_size: usize, dist_fn: D, ) -> Result<Box<dyn Send + Sync + NearestNeighbourIndex<F> + 'a>, BuildError>

Builds a spatial index using a MxN two-dimensional array representing M points with N dimensions. Also takes leaf_size, which specifies the number of elements in the leaf nodes of tree-like index structures.

Returns an error if the points have dimensionality of 0 or if the leaf size is 0. If any value in the batch is NaN or infinite, the behaviour is unspecified.

Provided Methods§

Source

fn from_batch<'a, F: Float, DT: Data<Elem = F>, D: 'a + Distance<F>>( &self, batch: &'a ArrayBase<DT, Ix2>, dist_fn: D, ) -> Result<Box<dyn Send + Sync + NearestNeighbourIndex<F> + 'a>, BuildError>

Builds a spatial index using a default leaf size. See from_batch_with_leaf_size for more information.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§