Struct Grid2d

Source
pub struct Grid2d<T> { /* private fields */ }

Implementations§

Source§

impl<T> Grid2d<T>
where T: Clone + Send + Sync,

Source

pub fn new(cols: usize, rows: usize, fill: T) -> Self

Source

pub fn with_cells(cols: usize, cells: Vec<T>) -> Self

Source

pub fn resize(&mut self, cols: usize, rows: usize, default: T)

Source

pub fn cols(&self) -> usize

Source

pub fn rows(&self) -> usize

Source

pub fn size(&self) -> (usize, usize)

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn cells(&self) -> &[T]

Source

pub fn cells_mut(&mut self) -> &mut [T]

Source

pub fn cell(&self, col: usize, row: usize) -> Option<&T>

Source

pub fn cell_mut(&mut self, col: usize, row: usize) -> Option<&mut T>

Source

pub fn get(&self, col: usize, row: usize) -> Option<T>

Source

pub fn set(&mut self, col: usize, row: usize, value: T)

Source

pub fn get_col_cells(&self, index: usize) -> Option<Vec<T>>

Source

pub fn get_row_cells(&self, index: usize) -> Option<Vec<T>>

Source

pub fn copy_part(&self, range: Range<(usize, usize)>, result: &mut Self)
where T: Default,

Source

pub fn get_part(&self, range: Range<(usize, usize)>) -> Self

Source

pub fn get_part_seamless(&self, range: Range<(usize, usize)>) -> Self

Source

pub fn get_view(&self, range: Range<(usize, usize)>) -> Grid2d<&T>

Source

pub fn get_view_seamless(&self, range: Range<(usize, usize)>) -> Grid2d<&T>

Source

pub fn copy_sample( &self, (col, row): (usize, usize), margin: usize, result: &mut Self, )
where T: Default,

Source

pub fn sample(&self, (col, row): (usize, usize), margin: usize) -> Self

Source

pub fn sample_seamless(&self, (col, row): (usize, usize), margin: usize) -> Self

Source

pub fn view_sample( &self, (col, row): (usize, usize), margin: usize, ) -> Grid2d<&T>

Source

pub fn view_sample_seamless( &self, (col, row): (usize, usize), margin: usize, ) -> Grid2d<&T>

Source

pub fn map<F, R>(&self, f: F) -> Grid2d<R>
where F: FnMut(usize, usize, &T) -> R, R: Clone + Send + Sync,

Source

pub fn with<F>(&mut self, f: F)
where F: FnMut(usize, usize, &T) -> T,

Source

pub fn iter(&self) -> impl DoubleEndedIterator<Item = &T>

Source

pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut T>

Source

pub fn iter_view( &self, range: Range<(usize, usize)>, ) -> impl DoubleEndedIterator<Item = (usize, usize, &T)>

Source

pub fn iter_view_mut( &mut self, range: Range<(usize, usize)>, ) -> impl DoubleEndedIterator<Item = (usize, usize, &mut T)>

Source

pub fn iter_sample( &self, range: Range<(usize, usize)>, margin: usize, ) -> impl DoubleEndedIterator<Item = (usize, usize, Grid2d<&T>)> + '_

Source

pub fn neighbor_sample( &self, (col, row): (usize, usize), ) -> Grid2dNeighborSample<T>
where T: Default + Copy,

Source

pub fn windows( &self, (cols, rows): (usize, usize), ) -> impl DoubleEndedIterator<Item = Grid2d<&T>>

Source

pub fn windows_seamless( &self, (cols, rows): (usize, usize), ) -> impl DoubleEndedIterator<Item = Grid2d<&T>>

Source

pub fn into_inner(self) -> (usize, usize, Vec<T>)

Source

pub fn from_view(view: &Grid2d<&T>) -> Self

Source

pub fn get_common_areas( first_size: (usize, usize), second_size: (usize, usize), second_offset: (usize, usize), ) -> Option<Grid2dCommonAreas>

Source

pub fn access_decoupled<'a>( &'a self, read: &[(usize, usize)], write: &[(usize, usize)], reads: &mut [&'a T], writes: &mut [&'a mut T], ) -> Result<(), Grid2dError>

Source

pub unsafe fn access_decoupled_unsafe<'a>( &'a self, read: &[(usize, usize)], write: &[(usize, usize)], reads: &mut [&'a T], writes: &mut [&'a mut T], ) -> Result<(), Grid2dError>

Source§

impl<T> Grid2d<T>
where T: Clone + Send + Sync + PartialEq,

Source

pub fn has_union_with( &self, other: &Self, offset_col: usize, offset_row: usize, ) -> bool

Trait Implementations§

Source§

impl<T> Add for &Grid2d<T>
where T: Clone + Send + Sync + Add<Output = T>,

Source§

type Output = Result<Grid2d<T>, Grid2dError>

The resulting type after applying the + operator.
Source§

fn add(self, other: &Grid2d<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for Grid2d<T>

Source§

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

Returns a duplicate 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> Debug for Grid2d<T>

Source§

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

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

impl<T: Default> Default for Grid2d<T>

Source§

fn default() -> Grid2d<T>

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

impl<'de, T> Deserialize<'de> for Grid2d<T>
where T: Deserialize<'de>,

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> Div for &Grid2d<T>
where T: Clone + Send + Sync + Div<Output = T>,

Source§

type Output = Result<Grid2d<T>, Grid2dError>

The resulting type after applying the / operator.
Source§

fn div(self, other: &Grid2d<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<I, T> From<(usize, I)> for Grid2d<T>
where I: Iterator<Item = T>, T: Clone + Send + Sync,

Source§

fn from((cols, iter): (usize, I)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Grid2d<T>> for (usize, usize, Vec<T>)
where T: Clone + Send + Sync,

Source§

fn from(v: Grid2d<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Grid2d<T>> for Vec<T>

Source§

fn from(v: Grid2d<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> Index<[usize; 2]> for Grid2d<T>
where T: Clone + Send + Sync,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, [col, row]: [usize; 2]) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> Index<(usize, usize)> for Grid2d<T>
where T: Clone + Send + Sync,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, (col, row): (usize, usize)) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<[usize; 2]> for Grid2d<T>
where T: Clone + Send + Sync,

Source§

fn index_mut(&mut self, [col, row]: [usize; 2]) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<(usize, usize)> for Grid2d<T>
where T: Clone + Send + Sync,

Source§

fn index_mut(&mut self, (col, row): (usize, usize)) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> IntoIterator for Grid2d<T>
where T: Clone + Send + Sync,

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> Mul for &Grid2d<T>
where T: Clone + Send + Sync + Mul<Output = T>,

Source§

type Output = Result<Grid2d<T>, Grid2dError>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &Grid2d<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Neg for &Grid2d<T>
where T: Clone + Send + Sync + Neg<Output = T>,

Source§

type Output = Grid2d<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> PartialEq for Grid2d<T>
where T: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Grid2d<T>
where T: 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> Sub for &Grid2d<T>
where T: Clone + Send + Sync + Sub<Output = T>,

Source§

type Output = Result<Grid2d<T>, Grid2dError>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &Grid2d<T>) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Grid2d<T>

§

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

§

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

§

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

§

impl<T> Unpin for Grid2d<T>
where T: Unpin,

§

impl<T> UnwindSafe for Grid2d<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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