From 5f85a59d4be37d350bcf1ee62c25ac1f84d71770 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 6 Jul 2020 22:24:02 -0400 Subject: kd: Use a more traditional k-d tree implementation The slight extra pruning possible in the previous implementation didn't seem to be worth it. The new, simpler implementation is also about 30% faster in most of the benchmarks. This gets rid of Coordinate{Proximity,Metric} as they're not necessary any more (and the old ExactNeighbors impl was too restrictive anyway). --- src/coords.rs | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'src/coords.rs') diff --git a/src/coords.rs b/src/coords.rs index 2e292ae..7c83946 100644 --- a/src/coords.rs +++ b/src/coords.rs @@ -1,6 +1,6 @@ //! [Coordinate spaces](https://en.wikipedia.org/wiki/Cartesian_coordinate_system). -use crate::distance::{Distance, Value}; +use crate::distance::Value; /// A coordinate space. pub trait Coordinates { @@ -88,26 +88,3 @@ impl Coordinates for &T { (*self).coord(i) } } - -/// Types that support computing distances to raw slices of coordinates. -pub trait CoordinateProximity { - type Distance: Distance; - - /// Compute the distance to a point specified by its coordinates. - fn distance_to_coords(&self, coords: &[T]) -> Self::Distance; -} - -/// Blanket [`CoordinateProximity`] implementation for references. -impl, U> CoordinateProximity for &T { - type Distance = T::Distance; - - fn distance_to_coords(&self, coords: &[U]) -> Self::Distance { - (*self).distance_to_coords(coords) - } -} - -/// Marker trait for coordinate proximities that are [metrics][crate::distance::Metric]. -pub trait CoordinateMetric: CoordinateProximity {} - -/// Blanket [`CoordinateMetric`] implementation for references. -impl, U> CoordinateMetric for &T {} -- cgit v1.2.3