From 48a8abb94e1318f67bbd2809186c62009456d7c6 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 5 May 2020 16:30:34 -0400 Subject: metric: Relax Distances to have only a partial order --- src/metric/vp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/metric/vp.rs') diff --git a/src/metric/vp.rs b/src/metric/vp.rs index fae62e5..d6e05df 100644 --- a/src/metric/vp.rs +++ b/src/metric/vp.rs @@ -1,6 +1,6 @@ //! [Vantage-point trees](https://en.wikipedia.org/wiki/Vantage-point_tree). -use super::{Metric, NearestNeighbors, Neighborhood}; +use super::{Metric, NearestNeighbors, Neighborhood, Ordered}; use std::iter::FromIterator; @@ -29,7 +29,7 @@ impl VpNode { fn build(slice: &mut [VpNode]) { if let Some((node, children)) = slice.split_first_mut() { let item = &node.item; - children.sort_by_cached_key(|n| item.distance(&n.item)); + children.sort_by_cached_key(|n| Ordered(item.distance(&n.item))); let (inside, outside) = children.split_at_mut(children.len() / 2); if let Some(last) = inside.last() { -- cgit v1.2.3