summaryrefslogtreecommitdiffstats
path: root/src/metric/vp.rs
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-05-05 16:30:34 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-05-05 16:30:34 -0400
commit48a8abb94e1318f67bbd2809186c62009456d7c6 (patch)
tree7977a218ef2e935a4f4f43b65c27cb4377dd0f2f /src/metric/vp.rs
parentbae2b127e377842a8131901cdb83ed4598bb3f21 (diff)
downloadkd-forest-48a8abb94e1318f67bbd2809186c62009456d7c6.tar.xz
metric: Relax Distances to have only a partial order
Diffstat (limited to 'src/metric/vp.rs')
-rw-r--r--src/metric/vp.rs4
1 files changed, 2 insertions, 2 deletions
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<T: Metric> VpNode<T> {
fn build(slice: &mut [VpNode<T>]) {
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() {