Trait kd_tree::KdPoint

source ·
pub trait KdPoint {
    type Scalar: NumAssign + Copy + PartialOrd;
    type Dim: Unsigned;

    // Required method
    fn at(&self, i: usize) -> Self::Scalar;

    // Provided method
    fn dim() -> usize { ... }
}
Expand description

A trait to represent k-dimensional point.

Example

struct MyItem {
    point: [f64; 3],
    id: usize,
}
impl kd_tree::KdPoint for MyItem {
    type Scalar = f64;
    type Dim = typenum::U3;
    fn at(&self, k: usize) -> f64 { self.point[k] }
}
let kdtree: kd_tree::KdTree<MyItem> = kd_tree::KdTree::build_by_ordered_float(vec![
    MyItem { point: [1.0, 2.0, 3.0], id: 111 },
    MyItem { point: [3.0, 1.0, 2.0], id: 222 },
    MyItem { point: [2.0, 3.0, 1.0], id: 333 },
]);
assert_eq!(kdtree.nearest(&[3.1, 0.1, 2.2]).unwrap().item.id, 222);

Required Associated Types§

Required Methods§

source

fn at(&self, i: usize) -> Self::Scalar

Provided Methods§

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<P: KdPoint, T> KdPoint for (P, T)

§

type Scalar = <P as KdPoint>::Scalar

§

type Dim = <P as KdPoint>::Dim

source§

fn at(&self, k: usize) -> Self::Scalar

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 1]

§

type Scalar = T

§

type Dim = UInt<UTerm, B1>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 2]

§

type Scalar = T

§

type Dim = UInt<UInt<UTerm, B1>, B0>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 3]

§

type Scalar = T

§

type Dim = UInt<UInt<UTerm, B1>, B1>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 4]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UTerm, B1>, B0>, B0>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 5]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UTerm, B1>, B0>, B1>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 6]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UTerm, B1>, B1>, B0>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 7]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UTerm, B1>, B1>, B1>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 8]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 9]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 10]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B1>, B0>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 11]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B1>, B1>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 12]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 13]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B1>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 14]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B0>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 15]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B1>

source§

fn at(&self, i: usize) -> T

source§

impl<T: NumAssign + Copy + PartialOrd> KdPoint for [T; 16]

§

type Scalar = T

§

type Dim = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>

source§

fn at(&self, i: usize) -> T

Implementors§