summaryrefslogtreecommitdiffstats
path: root/src/metric
diff options
context:
space:
mode:
Diffstat (limited to 'src/metric')
-rw-r--r--src/metric/kd.rs6
-rw-r--r--src/metric/vp.rs4
2 files changed, 4 insertions, 6 deletions
diff --git a/src/metric/kd.rs b/src/metric/kd.rs
index 2caf4a3..6ea3809 100644
--- a/src/metric/kd.rs
+++ b/src/metric/kd.rs
@@ -1,8 +1,6 @@
//! [k-d trees](https://en.wikipedia.org/wiki/K-d_tree).
-use super::{Metric, NearestNeighbors, Neighborhood};
-
-use ordered_float::OrderedFloat;
+use super::{Metric, NearestNeighbors, Neighborhood, Ordered};
use std::iter::FromIterator;
@@ -82,7 +80,7 @@ impl<T: Cartesian> KdNode<T> {
return;
}
- slice.sort_unstable_by_key(|n| OrderedFloat::from(n.item.coordinate(i)));
+ slice.sort_unstable_by_key(|n| Ordered(n.item.coordinate(i)));
let mid = slice.len() / 2;
slice.swap(0, mid);
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() {