pub struct Set<T>where
T: Ord,{ /* private fields */ }
Expand description
The set of coordinates/vectors in a plane, optimized for being in the plane.
Members of the set are Vec2<T>
.
Implementations§
source§impl<T> Set<T>where
T: Ord,
impl<T> Set<T>where T: Ord,
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of the set, i.e. how many Vec2
are stored in this
set.
sourcepub fn contains<U>(&self, point: Vec2<&U>) -> boolwhere
T: Borrow<U>,
U: Ord,
pub fn contains<U>(&self, point: Vec2<&U>) -> boolwhere T: Borrow<U>, U: Ord,
Tests if the set contains a given point.
sourcepub fn neighbours<U>(
&self,
point: Vec2<&U>,
direction: Direction
) -> Neighbours<'_, T> ⓘwhere
T: Borrow<U>,
U: Ord,
pub fn neighbours<U>( &self, point: Vec2<&U>, direction: Direction ) -> Neighbours<'_, T> ⓘwhere T: Borrow<U>, U: Ord,
Returns an iterator to the neighbours of a given point in a straight line in the given direction. The starting point is NOT included.
sourcepub fn neighbours_incl<U>(
&self,
point: Vec2<&U>,
direction: Direction
) -> Neighbours<'_, T> ⓘwhere
T: Borrow<U>,
U: Ord,
pub fn neighbours_incl<U>( &self, point: Vec2<&U>, direction: Direction ) -> Neighbours<'_, T> ⓘwhere T: Borrow<U>, U: Ord,
Returns an iterator to the neighbours of a given point in a straight line in the given direction. The starting point IS included.
sourcepub fn first_neighbour<U>(
&self,
point: Vec2<&U>,
direction: Direction
) -> Option<Vec2<&T>>where
U: Ord,
T: Borrow<U>,
pub fn first_neighbour<U>( &self, point: Vec2<&U>, direction: Direction ) -> Option<Vec2<&T>>where U: Ord, T: Borrow<U>,
Returns the nearest neighbour in a straight line of a given point in the the given direction.
sourcepub fn last_neighbour<U>(
&self,
point: Vec2<&U>,
direction: Direction
) -> Option<Vec2<&T>>where
U: Ord,
T: Borrow<U>,
pub fn last_neighbour<U>( &self, point: Vec2<&U>, direction: Direction ) -> Option<Vec2<&T>>where U: Ord, T: Borrow<U>,
Returns the furthest neighbour in a straight line of a given point in the given direction.
sourcepub fn insert(&mut self, point: Vec2<T>) -> boolwhere
T: Clone,
pub fn insert(&mut self, point: Vec2<T>) -> boolwhere T: Clone,
Inserts the given point in the set. Returns whether the insertion actually happened (i.e. the point was not already in the set).
sourcepub fn remove<U>(&mut self, point: Vec2<&U>) -> boolwhere
U: Ord,
T: Borrow<U>,
pub fn remove<U>(&mut self, point: Vec2<&U>) -> boolwhere U: Ord, T: Borrow<U>,
Removes a point from the set. Returns whether the removal actuall happened (i.e. the point was in the set).
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for Set<T>where
T: Ord + Deserialize<'de> + Clone,
impl<'de, T> Deserialize<'de> for Set<T>where T: Ord + Deserialize<'de> + Clone,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<T> Extend<Vec2<T>> for Set<T>where
T: Ord + Clone,
impl<T> Extend<Vec2<T>> for Set<T>where T: Ord + Clone,
source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = Vec2<T>>,
fn extend<I>(&mut self, iter: I)where I: IntoIterator<Item = Vec2<T>>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)