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_view(&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 view_sample( &self, (col, row): (usize, usize), margin: usize, ) -> Grid2d<&T>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

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> 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> Into<(usize, usize, Vec<T>)> for Grid2d<T>
where T: Clone + Send + Sync,

Source§

fn into(self) -> (usize, usize, Vec<T>)

Converts this type into the (usually inferred) input type.
Source§

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

Source§

fn into(self) -> Vec<T>

Converts this type into the (usually inferred) input type.
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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,