rust_sc2::distance

Trait DistanceIterator

Source
pub trait DistanceIterator: Iterator + Sized
where Self::Item: Distance + Copy,
{ // Provided methods fn closer<T: Into<Point2>>(self, distance: f32, target: T) -> Closer<Self> { ... } fn further<T: Into<Point2>>(self, distance: f32, target: T) -> Further<Self> { ... } fn closest<T: Into<Point2>>(self, target: T) -> Option<Self::Item> { ... } fn furthest<T: Into<Point2>>(self, target: T) -> Option<Self::Item> { ... } fn closest_distance<T: Into<Point2>>(self, target: T) -> Option<f32> { ... } fn furthest_distance<T: Into<Point2>>(self, target: T) -> Option<f32> { ... } fn closest_distance_squared<T: Into<Point2>>(self, target: T) -> Option<f32> { ... } fn furthest_distance_squared<T: Into<Point2>>( self, target: T, ) -> Option<f32> { ... } fn sort_by_distance<T: Into<Point2>>( self, target: T, ) -> IntoIter<Self::Item> { ... } fn sort_unstable_by_distance<T: Into<Point2>>( self, target: T, ) -> IntoIter<Self::Item> { ... } }
Expand description

Helper trait for iterators of items implementing Distance.

Provided Methods§

Source

fn closer<T: Into<Point2>>(self, distance: f32, target: T) -> Closer<Self>

Filters all items closer than given distance to target.

Source

fn further<T: Into<Point2>>(self, distance: f32, target: T) -> Further<Self>

Filters all items further than given distance to target.

Source

fn closest<T: Into<Point2>>(self, target: T) -> Option<Self::Item>

Returns closest to target item in iterator.

Source

fn furthest<T: Into<Point2>>(self, target: T) -> Option<Self::Item>

Returns furthest to target item in iterator.

Source

fn closest_distance<T: Into<Point2>>(self, target: T) -> Option<f32>

Returns distance to closest to target item in iterator.

Source

fn furthest_distance<T: Into<Point2>>(self, target: T) -> Option<f32>

Returns distance to furthest to target item in iterator.

Source

fn closest_distance_squared<T: Into<Point2>>(self, target: T) -> Option<f32>

Returns squared distance to closest to target item in iterator.

Source

fn furthest_distance_squared<T: Into<Point2>>(self, target: T) -> Option<f32>

Returns squared distance to furthest to target item in iterator.

Source

fn sort_by_distance<T: Into<Point2>>(self, target: T) -> IntoIter<Self::Item>

Returns iterator of items sorted 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.

Source

fn sort_unstable_by_distance<T: Into<Point2>>( self, target: T, ) -> IntoIter<Self::Item>

Returns iterator of items sorted 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.

Implementors§

Source§

impl<I> DistanceIterator for I
where I: Iterator + Sized, I::Item: Distance + Copy,