use crate::geometry::Point;
use num_traits::float::Float;
use std::cmp::Ordering;
#[derive(Copy, Clone, PartialEq)]
pub struct NearestNeighborState<F>
where
F: Float,
{
pub distance: F,
pub point: Point<F>,
}
impl<F: Float> Eq for NearestNeighborState<F> {}
impl<F> PartialOrd for NearestNeighborState<F>
where
F: Float,
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<F> Ord for NearestNeighborState<F>
where
F: Float,
{
fn cmp(&self, other: &Self) -> Ordering {
other.distance.partial_cmp(&self.distance).unwrap_or(Ordering::Equal)
}
}