pub trait DistanceSlice<T> {
// Required methods
fn sort_by_distance<P: Into<Point2>>(&mut self, target: P);
fn sort_unstable_by_distance<P: Into<Point2>>(&mut self, target: P);
}
Expand description
Helper trait for sorting by distance slice
and Vec
of elements implementing Distance
.
Required Methods§
Sourcefn sort_by_distance<P: Into<Point2>>(&mut self, target: P)
fn sort_by_distance<P: Into<Point2>>(&mut self, target: P)
Sorts slice by distance to target.
This sort is stable (i.e., does not reorder equal elements) and O(n * log(n))
worst-case.
When applicable, unstable sorting is preferred because it is generally faster than stable sorting
and it doesn’t allocate auxiliary memory. See sort_unstable_by_distance
.
Sourcefn sort_unstable_by_distance<P: Into<Point2>>(&mut self, target: P)
fn sort_unstable_by_distance<P: Into<Point2>>(&mut self, target: P)
Sorts slice by distance to target.
This sort is unstable (i.e., may reorder equal elements),
in-place (i.e., does not allocate), and O(n * log(n))
worst-case.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.