Trait 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§

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.

Implementations on Foreign Types§

Source§

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

Source§

type Scalar = <P as KdPoint>::Scalar

Source§

type Dim = <P as KdPoint>::Dim

Source§

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

Source§

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

Source§

type Scalar = T

Source§

type Dim = UInt<UTerm, B1>

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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]

Source§

type Scalar = T

Source§

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

Source§

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

Implementors§