Struct gridsim::SquareGrid [−][src]
pub struct SquareGrid<'a, S: Sim<'a>> { /* fields omitted */ }
Represents the state of the simulation.
Methods
impl<'a, S: Sim<'a>> SquareGrid<'a, S>
[src]
impl<'a, S: Sim<'a>> SquareGrid<'a, S>
pub fn new(width: usize, height: usize) -> Self where
S::Cell: Default,
[src]
pub fn new(width: usize, height: usize) -> Self where
S::Cell: Default,
Make a new grid using the Cell's Default impl.
pub fn new_default(width: usize, height: usize, default: S::Cell) -> Self where
S::Cell: Clone,
[src]
pub fn new_default(width: usize, height: usize, default: S::Cell) -> Self where
S::Cell: Clone,
Make a new grid by cloning a default Cell.
pub fn new_iter<I>(width: usize, height: usize, iter: I) -> Self where
I: IntoIterator<Item = S::Cell>,
[src]
pub fn new_iter<I>(width: usize, height: usize, iter: I) -> Self where
I: IntoIterator<Item = S::Cell>,
Make a new grid directly from an initial iter.
pub fn new_coord_map<F>(width: usize, height: usize, coord_map: F) -> Self where
F: FnMut(isize, isize) -> S::Cell,
[src]
pub fn new_coord_map<F>(width: usize, height: usize, coord_map: F) -> Self where
F: FnMut(isize, isize) -> S::Cell,
Make a grid by evaluating each centered signed coordinate to a cell with a closure.
pub fn new_coords<I>(width: usize, height: usize, coords: I) -> Self where
I: IntoIterator<Item = ((isize, isize), S::Cell)>,
S::Cell: Default,
[src]
pub fn new_coords<I>(width: usize, height: usize, coords: I) -> Self where
I: IntoIterator<Item = ((isize, isize), S::Cell)>,
S::Cell: Default,
Make a grid using a collection of centered signed coordinates with associated cells.
pub fn new_true_coords<I>(width: usize, height: usize, coords: I) -> Self where
I: IntoIterator<Item = (isize, isize)>,
S: Sim<'a, Cell = bool>,
[src]
pub fn new_true_coords<I>(width: usize, height: usize, coords: I) -> Self where
I: IntoIterator<Item = (isize, isize)>,
S: Sim<'a, Cell = bool>,
Make a grid using a collection of centered signed coordinates that indicate true cells.
pub fn delta_index(&self, i: usize, delta: (isize, isize)) -> usize
[src]
pub fn delta_index(&self, i: usize, delta: (isize, isize)) -> usize
Offset an index to a new index.
pub fn get_cell(&self, i: usize) -> &S::Cell
[src]
pub fn get_cell(&self, i: usize) -> &S::Cell
Get a &Cell. Panics if out of bounds.
pub fn get_cell_at(&self, x: usize, y: usize) -> &S::Cell
[src]
pub fn get_cell_at(&self, x: usize, y: usize) -> &S::Cell
Get a &Cell. Panics if out of bounds.
pub unsafe fn get_cell_unchecked(&self, i: usize) -> &S::Cell
[src]
pub unsafe fn get_cell_unchecked(&self, i: usize) -> &S::Cell
Get a &Cell. Panics if out of bounds.
pub fn get_cell_mut(&mut self, i: usize) -> &mut S::Cell
[src]
pub fn get_cell_mut(&mut self, i: usize) -> &mut S::Cell
Get a &mut Cell. Panics if out of bounds.
pub fn get_cell_at_mut(&mut self, x: usize, y: usize) -> &mut S::Cell
[src]
pub fn get_cell_at_mut(&mut self, x: usize, y: usize) -> &mut S::Cell
Get a &mut Cell. Panics if out of bounds.
pub unsafe fn get_move_neighbors(&self, i: usize) -> &S::MoveNeighbors
[src]
pub unsafe fn get_move_neighbors(&self, i: usize) -> &S::MoveNeighbors
This can only be called in the trait TakeMoveDirection
when implmenting a new Neighborhood
.
pub unsafe fn get_diff(&self, i: usize) -> &S::Diff
[src]
pub unsafe fn get_diff(&self, i: usize) -> &S::Diff
This can only be called in the trait TakeMoveDirection
when implmenting a new Neighborhood
.
pub fn get_cells(&self) -> &[S::Cell]
[src]
pub fn get_cells(&self) -> &[S::Cell]
Get the Grid's Cell slice.
pub fn get_cells_mut(&mut self) -> &mut [S::Cell]
[src]
pub fn get_cells_mut(&mut self) -> &mut [S::Cell]
Get the Grid's Cell slice mutably.
pub fn get_width(&self) -> usize
[src]
pub fn get_width(&self) -> usize
Get the Grid's width.
pub fn get_height(&self) -> usize
[src]
pub fn get_height(&self) -> usize
Get the Grid's height.
pub fn size(&self) -> usize
[src]
pub fn size(&self) -> usize
Get the Grid's size.
impl<'a, S, C, D, M, N, MN> SquareGrid<'a, S> where
S: Sim<'a, Cell = C, Diff = D, Move = M, Neighbors = N, MoveNeighbors = MN> + 'a,
S::Cell: Sync + Send,
S::Diff: Sync + Send,
S::Move: Sync + Send,
S::Neighbors: Sync + Send,
S::MoveNeighbors: Sync + Send,
Self: GetNeighbors<'a, usize, N>,
Self: TakeMoveNeighbors<usize, MN>,
[src]
impl<'a, S, C, D, M, N, MN> SquareGrid<'a, S> where
S: Sim<'a, Cell = C, Diff = D, Move = M, Neighbors = N, MoveNeighbors = MN> + 'a,
S::Cell: Sync + Send,
S::Diff: Sync + Send,
S::Move: Sync + Send,
S::Neighbors: Sync + Send,
S::MoveNeighbors: Sync + Send,
Self: GetNeighbors<'a, usize, N>,
Self: TakeMoveNeighbors<usize, MN>,
impl<'a, S, C, D, M, N, MN> SquareGrid<'a, S> where
S: Sim<'a, Cell = C, Diff = D, Move = M, Neighbors = N, MoveNeighbors = MN> + 'a,
S::Cell: Sync + Send + Serialize + Deserialize<'dc> + 'a,
S::Diff: Sync + Send,
S::Move: Sync + Send,
S::Neighbors: Sync + Send,
S::MoveNeighbors: Sync + Send,
Self: GetNeighbors<'a, usize, N>,
Self: TakeMoveNeighbors<usize, MN>,
[src]
impl<'a, S, C, D, M, N, MN> SquareGrid<'a, S> where
S: Sim<'a, Cell = C, Diff = D, Move = M, Neighbors = N, MoveNeighbors = MN> + 'a,
S::Cell: Sync + Send + Serialize + Deserialize<'dc> + 'a,
S::Diff: Sync + Send,
S::Move: Sync + Send,
S::Neighbors: Sync + Send,
S::MoveNeighbors: Sync + Send,
Self: GetNeighbors<'a, usize, N>,
Self: TakeMoveNeighbors<usize, MN>,
pub unsafe fn cycle_multi<I0: Read, I1: Read, I2: Read, I3: Read, I4: Read, I5: Read, I6: Read, I7: Read, O0: Write, O1: Write, O2: Write, O3: Write, O4: Write, O5: Write, O6: Write, O7: Write>(
&mut self,
in_right: I0,
in_up_right: I1,
in_up: I2,
in_up_left: I3,
in_left: I4,
in_down_left: I5,
in_down: I6,
in_down_right: I7,
out_right: O0,
out_up_right: O1,
out_up: O2,
out_up_left: O3,
out_left: O4,
out_down_left: O5,
out_down: O6,
out_down_right: O7
) -> Result<()>
[src]
pub unsafe fn cycle_multi<I0: Read, I1: Read, I2: Read, I3: Read, I4: Read, I5: Read, I6: Read, I7: Read, O0: Write, O1: Write, O2: Write, O3: Write, O4: Write, O5: Write, O6: Write, O7: Write>(
&mut self,
in_right: I0,
in_up_right: I1,
in_up: I2,
in_up_left: I3,
in_left: I4,
in_down_left: I5,
in_down: I6,
in_down_right: I7,
out_right: O0,
out_up_right: O1,
out_up: O2,
out_up_left: O3,
out_left: O4,
out_down_left: O5,
out_down: O6,
out_down_right: O7
) -> Result<()>
Run the Grid for one cycle and parallelize the simulation.
Make sure the reads and writes are only connected to other SquareGrid::cycle
running
on any machine using THE EXACT SAME simulation or else there may be undefined behavior.
Trait Implementations
impl<'a, S: Clone + Sim<'a>> Clone for SquareGrid<'a, S> where
S::Cell: Clone,
S::Diff: Clone,
S::MoveNeighbors: Clone,
[src]
impl<'a, S: Clone + Sim<'a>> Clone for SquareGrid<'a, S> where
S::Cell: Clone,
S::Diff: Clone,
S::MoveNeighbors: Clone,
fn clone(&self) -> SquareGrid<'a, S>
[src]
fn clone(&self) -> SquareGrid<'a, S>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a, S: Debug + Sim<'a>> Debug for SquareGrid<'a, S> where
S::Cell: Debug,
S::Diff: Debug,
S::MoveNeighbors: Debug,
[src]
impl<'a, S: Debug + Sim<'a>> Debug for SquareGrid<'a, S> where
S::Cell: Debug,
S::Diff: Debug,
S::MoveNeighbors: Debug,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'a, S: Sim<'a>> TakeMoveNeighbors<usize, ()> for SquareGrid<'a, S>
[src]
impl<'a, S: Sim<'a>> TakeMoveNeighbors<usize, ()> for SquareGrid<'a, S>
unsafe fn take_move_neighbors(&self, _: usize)
[src]
unsafe fn take_move_neighbors(&self, _: usize)
This should be called exactly once for every index, making it unsafe. Read more
impl<'a, S, D> TakeDiff<usize, D> for SquareGrid<'a, S> where
S: Sim<'a, Diff = D>,
[src]
impl<'a, S, D> TakeDiff<usize, D> for SquareGrid<'a, S> where
S: Sim<'a, Diff = D>,
unsafe fn take_diff(&self, ix: usize) -> D
[src]
unsafe fn take_diff(&self, ix: usize) -> D
This should be called exactly once for every index, making it unsafe. Read more
impl<'a, C, S> GetNeighbors<'a, usize, Neighbors<&'a C>> for SquareGrid<'a, S> where
S: Sim<'a, Cell = C>,
[src]
impl<'a, C, S> GetNeighbors<'a, usize, Neighbors<&'a C>> for SquareGrid<'a, S> where
S: Sim<'a, Cell = C>,
fn get_neighbors(&'a self, ix: usize) -> Neighbors<&'a C>
[src]
fn get_neighbors(&'a self, ix: usize) -> Neighbors<&'a C>
impl<'a, S, M> TakeMoveDirection<usize, Direction, M> for SquareGrid<'a, S> where
S: Sim<'a, Move = M, MoveNeighbors = Neighbors<M>>,
[src]
impl<'a, S, M> TakeMoveDirection<usize, Direction, M> for SquareGrid<'a, S> where
S: Sim<'a, Move = M, MoveNeighbors = Neighbors<M>>,
unsafe fn take_move_direction(&self, ix: usize, dir: Direction) -> M
[src]
unsafe fn take_move_direction(&self, ix: usize, dir: Direction) -> M
This should be called exactly once for every index and direction. Read more
impl<'a, S, M> TakeMoveNeighbors<usize, Neighbors<M>> for SquareGrid<'a, S> where
S: Sim<'a, Move = M, MoveNeighbors = Neighbors<M>>,
[src]
impl<'a, S, M> TakeMoveNeighbors<usize, Neighbors<M>> for SquareGrid<'a, S> where
S: Sim<'a, Move = M, MoveNeighbors = Neighbors<M>>,
unsafe fn take_move_neighbors(&self, ix: usize) -> Neighbors<M>
[src]
unsafe fn take_move_neighbors(&self, ix: usize) -> Neighbors<M>
This should be called exactly once for every index, making it unsafe. Read more
impl<'a, C, S> GetNeighbors<'a, usize, Neighbors<&'a C>> for SquareGrid<'a, S> where
S: Sim<'a, Cell = C>,
[src]
impl<'a, C, S> GetNeighbors<'a, usize, Neighbors<&'a C>> for SquareGrid<'a, S> where
S: Sim<'a, Cell = C>,
fn get_neighbors(&'a self, ix: usize) -> Neighbors<&'a C>
[src]
fn get_neighbors(&'a self, ix: usize) -> Neighbors<&'a C>
impl<'a, S, M> TakeMoveDirection<usize, Direction, M> for SquareGrid<'a, S> where
S: Sim<'a, Move = M, MoveNeighbors = Neighbors<M>>,
[src]
impl<'a, S, M> TakeMoveDirection<usize, Direction, M> for SquareGrid<'a, S> where
S: Sim<'a, Move = M, MoveNeighbors = Neighbors<M>>,
unsafe fn take_move_direction(&self, ix: usize, dir: Direction) -> M
[src]
unsafe fn take_move_direction(&self, ix: usize, dir: Direction) -> M
This should be called exactly once for every index and direction. Read more
impl<'a, S, M> TakeMoveNeighbors<usize, Neighbors<M>> for SquareGrid<'a, S> where
S: Sim<'a, Move = M, MoveNeighbors = Neighbors<M>>,
[src]
impl<'a, S, M> TakeMoveNeighbors<usize, Neighbors<M>> for SquareGrid<'a, S> where
S: Sim<'a, Move = M, MoveNeighbors = Neighbors<M>>,
unsafe fn take_move_neighbors(&self, ix: usize) -> Neighbors<M>
[src]
unsafe fn take_move_neighbors(&self, ix: usize) -> Neighbors<M>
This should be called exactly once for every index, making it unsafe. Read more