Struct gardiz::set::Set

source ·
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,

source

pub fn new() -> Self

Creates a new empty set.

source

pub fn is_empty(&self) -> bool

Tests if the set is emtpy.

source

pub fn len(&self) -> usize

Returns the length of the set, i.e. how many Vec2 are stored in this set.

source

pub fn contains<U>(&self, point: Vec2<&U>) -> boolwhere T: Borrow<U>, U: Ord,

Tests if the set contains a given point.

source

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.

source

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.

source

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.

source

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.

source

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).

source

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).

source

pub fn rows(&self) -> Rows<'_, T>

Returns an iterator over all the points in the set, in the direction of rows (first point is the lowest), i.e. all X are yielded before going to the next Y.

source

pub fn columns(&self) -> Columns<'_, T>

Returns an iterator over all the points in the set, in the direction of columns (first point is the lowest), i.e. all Y are yielded before going to the next X.

Trait Implementations§

source§

impl<T> Clone for Set<T>where T: Ord + Clone,

source§

fn clone(&self) -> Set<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for Set<T>where T: Ord + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Default for Set<T>where T: Ord,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

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>>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T> FromIterator<Vec2<T>> for Set<T>where T: Ord + Clone,

source§

fn from_iter<I>(iter: I) -> Selfwhere I: IntoIterator<Item = Vec2<T>>,

Creates a value from an iterator. Read more
source§

impl<T> PartialEq<Set<T>> for Set<T>where T: Ord + PartialEq,

source§

fn eq(&self, other: &Set<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for Set<T>where T: Ord + Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Eq for Set<T>where T: Ord + Eq,

source§

impl<T> StructuralEq for Set<T>where T: Ord,

source§

impl<T> StructuralPartialEq for Set<T>where T: Ord,

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Set<T>where T: RefUnwindSafe,

§

impl<T> Send for Set<T>where T: Send,

§

impl<T> Sync for Set<T>where T: Sync,

§

impl<T> Unpin for Set<T>

§

impl<T> UnwindSafe for Set<T>where T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,