Skip to main content

IGrid

Trait IGrid 

Source
pub trait IGrid<T, Idx, const N: usize>:
    Sized
    + IRectangle<Idx, N>
    + Get<Vector<Idx, N>, Output = T, Output = T, Output = T>
    + Index<Vector<Idx, N>, Output = T, Output = T>
    + GetMut<Vector<Idx, N>>
    + GetManyMut<Vector<Idx, N>>
    + IndexMut<Vector<Idx, N>>
where Idx: Integer,
{ type WithType<U>: IGrid<U, Idx, N>;
Show 21 methods // Required methods fn values(&self) -> &[T]; fn values_mut(&mut self) -> &mut [T]; fn into_size_and_values(self) -> (Vector<Idx, N>, Vec<T>); unsafe fn from_vec_unchecked<P>(size: P, value: Vec<T>) -> Self where P: Into<Vector<Idx, N>>; // Provided methods fn into_values(self) -> Vec<T> { ... } unsafe fn position_to_index_unchecked<P>(&self, pos: P) -> usize where P: Into<Vector<Idx, N>> { ... } unsafe fn index_to_position_unchecked(&self, index: usize) -> Vector<Idx, N> { ... } unsafe fn external_position_to_position_unchecked<P>(pos: P, size: P) -> P where P: Into<Vector<Idx, N>> + From<Vector<Idx, N>> { ... } fn position_to_index<P>(&self, pos: P) -> Option<usize> where P: Into<Vector<Idx, N>> { ... } fn index_to_position(&self, index: usize) -> Option<Vector<Idx, N>> { ... } fn from_vec<P>(size: P, value: Vec<T>) -> Option<Self> where P: Into<Vector<Idx, N>> { ... } fn try_from_vec<P>( size: P, value: Vec<T>, ) -> Result<Self, GridBaseError<Idx, N>> where P: Into<Vector<Idx, N>> { ... } fn from_fn<P, F>(size: P, f: F) -> Self where F: FnMut(P) -> T, P: Into<Vector<Idx, N>>, Vector<Idx, N>: Into<P> { ... } fn from_fn_par<P, F>(size: P, f: F) -> Self where F: Fn(P) -> T + Sync, P: Into<Vector<Idx, N>>, Vector<Idx, N>: Into<P>, T: Send, Idx: Sync { ... } fn new(size: Vector<Idx, N>) -> Self where T: Default { ... } fn new_uniform(size: Vector<Idx, N>, value: T) -> Self where T: Clone { ... } fn from_fn_ndc<P, F>(size: P, f: F) -> Self where P: Into<Vector<Idx, N>>, Vector<Idx, N>: CastIntoComposite<f32, Output = Vector<f32, N>>, F: FnMut(Vector<f32, N>) -> T { ... } fn from_fn_ndc_with_precision<P, Precision, F>(size: P, f: F) -> Self where P: Into<Vector<Idx, N>>, Precision: Float, Vector<Idx, N>: CastIntoComposite<Precision, Output = Vector<Precision, N>>, F: FnMut(Vector<Precision, N>) -> T { ... } fn from_fn_normalized<P, F>(size: P, f: F) -> Self where P: Into<Vector<Idx, N>>, Vector<Idx, N>: CastIntoComposite<f32, Output = Vector<f32, N>>, F: FnMut(Vector<f32, N>) -> T { ... } fn from_fn_normalized_with_precision<P, Precision, F>(size: P, f: F) -> Self where P: Into<Vector<Idx, N>>, Precision: Float, Vector<Idx, N>: CastIntoComposite<Precision, Output = Vector<Precision, N>>, F: FnMut(Vector<Precision, N>) -> T { ... } fn map<Dest, F>(self, f: F) -> Self::WithType<Dest> where F: FnMut(T) -> Dest { ... }
}

Required Associated Types§

Source

type WithType<U>: IGrid<U, Idx, N>

Required Methods§

Source

fn values(&self) -> &[T]

Source

fn values_mut(&mut self) -> &mut [T]

Source

fn into_size_and_values(self) -> (Vector<Idx, N>, Vec<T>)

Source

unsafe fn from_vec_unchecked<P>(size: P, value: Vec<T>) -> Self
where P: Into<Vector<Idx, N>>,

Provided Methods§

Source

fn into_values(self) -> Vec<T>

Source

unsafe fn position_to_index_unchecked<P>(&self, pos: P) -> usize
where P: Into<Vector<Idx, N>>,

Used for the memory bijection between the one dimensional vector and the N-dimensional grid.

If you override this, you probably also want to override IGrid::index_to_position_unchecked and IGrid::external_position_to_position_unchecked

Source

unsafe fn index_to_position_unchecked(&self, index: usize) -> Vector<Idx, N>

Used for the memory bijection between the one dimensional vector and the N-dimensional grid.

If you override this, you probably also want to override IGrid::position_to_index_unchecked and IGrid::external_position_to_position_unchecked

Source

unsafe fn external_position_to_position_unchecked<P>(pos: P, size: P) -> P
where P: Into<Vector<Idx, N>> + From<Vector<Idx, N>>,

Used for the memory bijection between the one dimensional vector and the N-dimensional grid.

If you override this, you probably also want to override IGrid::position_to_index_unchecked and IGrid::index_to_position_unchecked

Source

fn position_to_index<P>(&self, pos: P) -> Option<usize>
where P: Into<Vector<Idx, N>>,

Used for the memory bijection between the one dimensional vector and the N-dimensional grid.

Source

fn index_to_position(&self, index: usize) -> Option<Vector<Idx, N>>

Used for the memory bijection between the one dimensional vector and the N-dimensional grid.

Source

fn from_vec<P>(size: P, value: Vec<T>) -> Option<Self>
where P: Into<Vector<Idx, N>>,

Source

fn try_from_vec<P>( size: P, value: Vec<T>, ) -> Result<Self, GridBaseError<Idx, N>>
where P: Into<Vector<Idx, N>>,

Source

fn from_fn<P, F>(size: P, f: F) -> Self
where F: FnMut(P) -> T, P: Into<Vector<Idx, N>>, Vector<Idx, N>: Into<P>,

Create a grid from a function

Source

fn from_fn_par<P, F>(size: P, f: F) -> Self
where F: Fn(P) -> T + Sync, P: Into<Vector<Idx, N>>, Vector<Idx, N>: Into<P>, T: Send, Idx: Sync,

Create a grid from a function in parallel

Source

fn new(size: Vector<Idx, N>) -> Self
where T: Default,

Create a new grid and fill it with the Default value

Source

fn new_uniform(size: Vector<Idx, N>, value: T) -> Self
where T: Clone,

Create a new grid and fill it by Clone the value

Source

fn from_fn_ndc<P, F>(size: P, f: F) -> Self
where P: Into<Vector<Idx, N>>, Vector<Idx, N>: CastIntoComposite<f32, Output = Vector<f32, N>>, F: FnMut(Vector<f32, N>) -> T,

Create a grid from a Normalized Device Coordinates.

Each component of the vector will be between -1.0..=1.0

Source

fn from_fn_ndc_with_precision<P, Precision, F>(size: P, f: F) -> Self
where P: Into<Vector<Idx, N>>, Precision: Float, Vector<Idx, N>: CastIntoComposite<Precision, Output = Vector<Precision, N>>, F: FnMut(Vector<Precision, N>) -> T,

Create a grid from a Normalized Device Coordinates.

Each component of the vector will be between -1.0..=1.0

Source

fn from_fn_normalized<P, F>(size: P, f: F) -> Self
where P: Into<Vector<Idx, N>>, Vector<Idx, N>: CastIntoComposite<f32, Output = Vector<f32, N>>, F: FnMut(Vector<f32, N>) -> T,

Create a grid from a Normalized Coordinates.

Each component of the vector will be between 0..=1.0

Source

fn from_fn_normalized_with_precision<P, Precision, F>(size: P, f: F) -> Self
where P: Into<Vector<Idx, N>>, Precision: Float, Vector<Idx, N>: CastIntoComposite<Precision, Output = Vector<Precision, N>>, F: FnMut(Vector<Precision, N>) -> T,

Create a grid from a Normalized Coordinates.

Each component of the vector will be between 0..=1.0

Source

fn map<Dest, F>(self, f: F) -> Self::WithType<Dest>
where F: FnMut(T) -> Dest,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<C, Idx> IGrid<C, Idx, 2> for ImageBase<C, Idx>
where Idx: Integer,

Source§

type WithType<U> = ImageBase<U, Idx>

Source§

fn values(&self) -> &[C]

Source§

fn values_mut(&mut self) -> &mut [C]

Source§

fn into_size_and_values(self) -> (Vector<Idx, 2>, Vec<C>)

Source§

unsafe fn from_vec_unchecked<P>(size: P, pixels: Vec<C>) -> ImageBase<C, Idx>
where P: Into<Vector<Idx, 2>>,

Source§

unsafe fn position_to_index_unchecked<P>(&self, pos: P) -> usize
where P: Into<Vector<Idx, 2>>,

Source§

unsafe fn index_to_position_unchecked(&self, index: usize) -> Vector<Idx, 2>

Source§

unsafe fn external_position_to_position_unchecked<P>(pos: P, size: P) -> P
where P: Into<Vector<Idx, 2>> + From<Vector<Idx, 2>>,

Implementors§

Source§

impl<T, Idx, const N: usize> IGrid<T, Idx, N> for GridBase<T, Idx, N>
where Idx: Integer,

Source§

type WithType<U> = GridBase<U, Idx, N>