Trait SurfaceGrid

Source
pub trait SurfaceGrid<T>:
    IndexMut<Self::Point>
    + Index<Self::Point, Output = T>
    + IntoIterator<Item = (Self::Point, T)> {
    type Point: GridPoint + Send;

Show 28 methods // Required methods fn from_fn<F: FnMut(&Self::Point) -> T>(f: F) -> Self; fn from_fn_par<F: Fn(&Self::Point) -> T + Send + Sync>(f: F) -> Self where T: Send + Sync; fn set_from_fn<F: FnMut(&Self::Point) -> T>(&mut self, f: F); fn set_from_fn_par<F: Fn(&Self::Point) -> T + Send + Sync>(&mut self, f: F) where T: Send + Sync; fn for_each(&mut self, f: impl FnMut(&mut T)); fn for_each_with_position(&mut self, f: impl FnMut(&Self::Point, &mut T)); fn par_for_each(&mut self, f: impl Fn(&mut T) + Sync) where T: Send + Sync; fn par_for_each_with_position( &mut self, f: impl Fn(&Self::Point, &mut T) + Sync, ) where T: Send + Sync; fn iter<'a>(&'a self) -> impl Iterator<Item = (Self::Point, &'a T)> where T: 'a; fn par_iter<'a>( &'a self, ) -> impl ParallelIterator<Item = (Self::Point, &'a T)> where T: 'a + Send + Sync; fn points(&self) -> impl Iterator<Item = Self::Point>; fn par_points(&self) -> impl ParallelIterator<Item = Self::Point>; // Provided methods fn map_neighbours<F: FnMut(&T, &T, &T, &T, &T) -> T>(&self, f: F) -> Self where Self: Sized { ... } fn map_neighbours_diagonals<F: FnMut(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T>( &self, f: F, ) -> Self where Self: Sized { ... } fn map_neighbours_par<F: Fn(&T, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F, ) -> Self where Self: Sized + Sync, T: Send + Sync { ... } fn map_neighbours_diagonals_par<F: Fn(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F, ) -> Self where Self: Sized + Sync, T: Send + Sync { ... } fn map_neighbours_with_position<F: FnMut(&T, &Self::Point, &T, &T, &T, &T) -> T>( &self, f: F, ) -> Self where Self: Sized { ... } fn map_neighbours_diagonals_with_position<F: FnMut(&Self::Point, &T, &T, &T, &T, &T, &T, &T, &T, &T) -> T>( &self, f: F, ) -> Self where Self: Sized { ... } fn map_neighbours_par_with_position<F: Fn(&T, &Self::Point, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F, ) -> Self where Self: Sized + Sync, T: Send + Sync { ... } fn map_neighbours_diagonals_par_with_position<F: Fn(&Self::Point, &T, &T, &T, &T, &T, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F, ) -> Self where Self: Sized + Sync, T: Send + Sync { ... } fn set_from_neighbours<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F, ) { ... } fn set_from_neighbours_diagonals<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &U, &U, &U, &U, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F, ) { ... } fn set_from_neighbours_par<U, G: SurfaceGrid<U, Point = Self::Point> + Sync, F: Fn(&U, &U, &U, &U, &U) -> T + Send + Sync>( &mut self, source: &G, f: F, ) where T: Send + Sync { ... } fn set_from_neighbours_diagonals_par<U, G: SurfaceGrid<U, Point = Self::Point> + Sync, F: Fn(&U, &U, &U, &U, &U, &U, &U, &U, &U) -> T + Send + Sync>( &mut self, source: &G, f: F, ) where T: Send + Sync { ... } fn set_from_neighbours_with_position<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &Self::Point, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F, ) { ... } fn set_from_neighbours_diagonals_with_position<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&Self::Point, &U, &U, &U, &U, &U, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F, ) { ... } fn set_from_neighbours_par_with_position<U, G: SurfaceGrid<U, Point = Self::Point> + Sync, F: Fn(&U, &Self::Point, &U, &U, &U, &U) -> T + Send + Sync>( &mut self, source: &G, f: F, ) where T: Send + Sync { ... } fn set_from_neighbours_diagonals_par_with_position<U, G: SurfaceGrid<U, Point = Self::Point> + Sync, F: Fn(&Self::Point, &U, &U, &U, &U, &U, &U, &U, &U, &U) -> T + Send + Sync>( &mut self, source: &G, f: F, ) where T: Send + Sync { ... }
}
Expand description

A grid wrapped around a surface.

Required Associated Types§

Source

type Point: GridPoint + Send

The type of a point on this grid.

Required Methods§

Source

fn from_fn<F: FnMut(&Self::Point) -> T>(f: F) -> Self

Creates a new surface grid by calling the specified function for each point in the grid.

  • f - The function to apply.
Source

fn from_fn_par<F: Fn(&Self::Point) -> T + Send + Sync>(f: F) -> Self
where T: Send + Sync,

Creates a new surface grid by calling the specified function in parallel for each point in the grid.

  • f - The function to apply.
Source

fn set_from_fn<F: FnMut(&Self::Point) -> T>(&mut self, f: F)

Updates this surface grid by calling the specified function for each point in the grid.

  • f - The function to apply.
Source

fn set_from_fn_par<F: Fn(&Self::Point) -> T + Send + Sync>(&mut self, f: F)
where T: Send + Sync,

Updates this surface grid by calling the specified function for each point in the grid in parallel.

  • f - The function to apply.
Source

fn for_each(&mut self, f: impl FnMut(&mut T))

Calls a function for each element on this grid.

  • f - The function to apply.
Source

fn for_each_with_position(&mut self, f: impl FnMut(&Self::Point, &mut T))

Calls a function for each element on this grid with the position.

  • f - The function to apply.
Source

fn par_for_each(&mut self, f: impl Fn(&mut T) + Sync)
where T: Send + Sync,

Calls a function for each element on this grid in parallel.

  • f - The function to apply.
Source

fn par_for_each_with_position( &mut self, f: impl Fn(&Self::Point, &mut T) + Sync, )
where T: Send + Sync,

Calls a function for each element on this grid with the position in parallel.

  • f - The function to apply.
Source

fn iter<'a>(&'a self) -> impl Iterator<Item = (Self::Point, &'a T)>
where T: 'a,

Iterates over the points in this grid and their values.

Source

fn par_iter<'a>(&'a self) -> impl ParallelIterator<Item = (Self::Point, &'a T)>
where T: 'a + Send + Sync,

Iterates over the points in this grid and their values in parallel.

Source

fn points(&self) -> impl Iterator<Item = Self::Point>

Iterates over the points in this grid.

Source

fn par_points(&self) -> impl ParallelIterator<Item = Self::Point>

Iterates over the points in this grid in parallel.

Provided Methods§

Source

fn map_neighbours<F: FnMut(&T, &T, &T, &T, &T) -> T>(&self, f: F) -> Self
where Self: Sized,

Applies a function to each cell and its direct neighbours.

The provided function is called with the arguments: current, up, down, left, right.

f - The function to apply.

Source

fn map_neighbours_diagonals<F: FnMut(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T>( &self, f: F, ) -> Self
where Self: Sized,

Applies a function to each cell and its direct neighbours including diagonals.

The provided function is called with the arguments: up_left, up, up_right, left, current, right, down_left, down, down_right.

f - The function to apply.

Source

fn map_neighbours_par<F: Fn(&T, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F, ) -> Self
where Self: Sized + Sync, T: Send + Sync,

Applies a function in parallel to each cell and its direct neighbours.

The provided function is called with the arguments: current, up, down, left, right.

f - The function to apply.

Source

fn map_neighbours_diagonals_par<F: Fn(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F, ) -> Self
where Self: Sized + Sync, T: Send + Sync,

Applies a function in parallel to each cell and its direct neighbours including diagonals.

The provided function is called with the arguments: up_left, up, up_right, left, current, right, down_left, down, down_right.

f - The function to apply.

Source

fn map_neighbours_with_position<F: FnMut(&T, &Self::Point, &T, &T, &T, &T) -> T>( &self, f: F, ) -> Self
where Self: Sized,

Applies a function to each cell and its direct neighbours providing the current point.

The provided function is called with the arguments: current, position, up, down, left, right.

f - The function to apply.

Source

fn map_neighbours_diagonals_with_position<F: FnMut(&Self::Point, &T, &T, &T, &T, &T, &T, &T, &T, &T) -> T>( &self, f: F, ) -> Self
where Self: Sized,

Applies a function to each cell and its direct neighbours including diagonals providing the current point.

The provided function is called with the arguments: position up_left, up, up_right, left, current, right, down_left, down, down_right.

f - The function to apply.

Source

fn map_neighbours_par_with_position<F: Fn(&T, &Self::Point, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F, ) -> Self
where Self: Sized + Sync, T: Send + Sync,

Applies a function in parallel to each cell and its direct neighbours providing the current point.

The provided function is called with the arguments: current, position, up, down, left, right.

f - The function to apply.

Source

fn map_neighbours_diagonals_par_with_position<F: Fn(&Self::Point, &T, &T, &T, &T, &T, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F, ) -> Self
where Self: Sized + Sync, T: Send + Sync,

Applies a function in parallel to each cell and its direct neighbours including diagonals providing the current point.

The provided function is called with the arguments: position, up_left, up, up_right, left, current, right, down_left, down, down_right.

f - The function to apply.

Source

fn set_from_neighbours<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F, )

Applies a function to each cell and its direct neighbours.

The provided function is called with the arguments: current, up, down, left, right.

source - The source grid from which to read data. f - The function to apply.

Source

fn set_from_neighbours_diagonals<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &U, &U, &U, &U, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F, )

Applies a function to each cell and its direct neighbours including diagonals.

The provided function is called with the arguments: up_left, up, up_right, left, current, right, down_left, down, down_right.

source - The source grid from which to read data. f - The function to apply.

Source

fn set_from_neighbours_par<U, G: SurfaceGrid<U, Point = Self::Point> + Sync, F: Fn(&U, &U, &U, &U, &U) -> T + Send + Sync>( &mut self, source: &G, f: F, )
where T: Send + Sync,

Applies a function to each cell and its direct neighbours in parallel.

The provided function is called with the arguments: current, up, down, left, right.

source - The source grid from which to read data. f - The function to apply.

Source

fn set_from_neighbours_diagonals_par<U, G: SurfaceGrid<U, Point = Self::Point> + Sync, F: Fn(&U, &U, &U, &U, &U, &U, &U, &U, &U) -> T + Send + Sync>( &mut self, source: &G, f: F, )
where T: Send + Sync,

Applies a function to each cell and its direct neighbours including diagonals in parallel.

The provided function is called with the arguments: up_left, up, up_right, left, current, right, down_left, down, down_right.

source - The source grid from which to read data. f - The function to apply.

Source

fn set_from_neighbours_with_position<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&U, &Self::Point, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F, )

Applies a function to each cell and its direct neighbours providing the position.

The provided function is called with the arguments: current, position, up, down, left, right.

source - The source grid from which to read data. f - The function to apply.

Source

fn set_from_neighbours_diagonals_with_position<U, G: SurfaceGrid<U, Point = Self::Point>, F: FnMut(&Self::Point, &U, &U, &U, &U, &U, &U, &U, &U, &U) -> T>( &mut self, source: &G, f: F, )

Applies a function to each cell and its direct neighbours including diagonals.

The provided function is called with the arguments: position, up_left, up, up_right, left, current, right, down_left, down, down_right.

source - The source grid from which to read data. f - The function to apply.

Source

fn set_from_neighbours_par_with_position<U, G: SurfaceGrid<U, Point = Self::Point> + Sync, F: Fn(&U, &Self::Point, &U, &U, &U, &U) -> T + Send + Sync>( &mut self, source: &G, f: F, )
where T: Send + Sync,

Applies a function to each cell and its direct neighbours in parallel.

The provided function is called with the arguments: current, position, up, down, left, right.

source - The source grid from which to read data. f - The function to apply.

Source

fn set_from_neighbours_diagonals_par_with_position<U, G: SurfaceGrid<U, Point = Self::Point> + Sync, F: Fn(&Self::Point, &U, &U, &U, &U, &U, &U, &U, &U, &U) -> T + Send + Sync>( &mut self, source: &G, f: F, )
where T: Send + Sync,

Applies a function to each cell and its direct neighbours including diagonals in parallel.

The provided function is called with the arguments: position, up_left, up, up_right, left, current, right, down_left, down, down_right.

source - The source grid from which to read data. f - The function to apply.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, const W: usize, const H: usize> SurfaceGrid<T> for RectangleSphereGrid<T, W, H>

Source§

impl<T: Debug, const S: usize> SurfaceGrid<T> for CubeSphereGrid<T, S>