Trait surface_grid::SurfaceGrid
source · pub trait SurfaceGrid<T>: IndexMut<Self::Point> + Index<Self::Point, Output = T> + IntoIterator<Item = (Self::Point, T)> {
type Point: GridPoint + Send;
Show 24 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 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§
Required Methods§
sourcefn from_fn<F: FnMut(&Self::Point) -> T>(f: F) -> Self
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.
sourcefn from_fn_par<F: Fn(&Self::Point) -> T + Send + Sync>(f: F) -> Self
fn from_fn_par<F: Fn(&Self::Point) -> T + Send + Sync>(f: F) -> Self
Creates a new surface grid by calling the specified function in parallel for each point in the grid.
f
- The function to apply.
sourcefn set_from_fn<F: FnMut(&Self::Point) -> T>(&mut self, f: F)
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.
sourcefn set_from_fn_par<F: Fn(&Self::Point) -> T + Send + Sync>(&mut self, f: F)
fn set_from_fn_par<F: Fn(&Self::Point) -> T + Send + Sync>(&mut self, f: F)
Updates this surface grid by calling the specified function for each point in the grid in parallel.
f
- The function to apply.
sourcefn iter<'a>(&'a self) -> impl Iterator<Item = (Self::Point, &'a T)>where
T: 'a,
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.
sourcefn par_iter<'a>(&'a self) -> impl ParallelIterator<Item = (Self::Point, &'a T)>
fn par_iter<'a>(&'a self) -> impl ParallelIterator<Item = (Self::Point, &'a T)>
Iterates over the points in this grid and their values in parallel.
sourcefn par_points(&self) -> impl ParallelIterator<Item = Self::Point>
fn par_points(&self) -> impl ParallelIterator<Item = Self::Point>
Iterates over the points in this grid in parallel.
Provided Methods§
sourcefn map_neighbours<F: FnMut(&T, &T, &T, &T, &T) -> T>(&self, f: F) -> Selfwhere
Self: Sized,
fn map_neighbours<F: FnMut(&T, &T, &T, &T, &T) -> T>(&self, f: F) -> Selfwhere
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.
sourcefn map_neighbours_diagonals<F: FnMut(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T>(
&self,
f: F
) -> Selfwhere
Self: Sized,
fn map_neighbours_diagonals<F: FnMut(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T>(
&self,
f: F
) -> Selfwhere
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.
sourcefn map_neighbours_par<F: Fn(&T, &T, &T, &T, &T) -> T + Send + Sync>(
&self,
f: F
) -> Self
fn map_neighbours_par<F: Fn(&T, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F ) -> Self
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.
sourcefn map_neighbours_diagonals_par<F: Fn(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T + Send + Sync>(
&self,
f: F
) -> Self
fn map_neighbours_diagonals_par<F: Fn(&T, &T, &T, &T, &T, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F ) -> Self
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.
sourcefn map_neighbours_with_position<F: FnMut(&T, &Self::Point, &T, &T, &T, &T) -> T>(
&self,
f: F
) -> Selfwhere
Self: Sized,
fn map_neighbours_with_position<F: FnMut(&T, &Self::Point, &T, &T, &T, &T) -> T>(
&self,
f: F
) -> Selfwhere
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.
sourcefn map_neighbours_diagonals_with_position<F: FnMut(&Self::Point, &T, &T, &T, &T, &T, &T, &T, &T, &T) -> T>(
&self,
f: F
) -> Selfwhere
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
) -> Selfwhere
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.
sourcefn map_neighbours_par_with_position<F: Fn(&T, &Self::Point, &T, &T, &T, &T) -> T + Send + Sync>(
&self,
f: F
) -> Self
fn map_neighbours_par_with_position<F: Fn(&T, &Self::Point, &T, &T, &T, &T) -> T + Send + Sync>( &self, f: F ) -> Self
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.
sourcefn 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
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
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.
sourcefn 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<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.
sourcefn 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_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.
sourcefn 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
)
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 )
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.
sourcefn 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
)
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 )
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.
sourcefn 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_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.
sourcefn 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_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.
sourcefn 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
)
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 )
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.
sourcefn 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
)
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 )
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.