[][src]Struct lysogeny_broth::Grid

pub struct Grid { /* fields omitted */ }

A structure to encode a grid with cells. Cell positions start at top left corner. The grid handles everything in terms of space. The retrieval methods for different neighbours allow for the implementation of different neighbourhoods (e.g. von Neumann, Moore ...) or even arbitrary functions to determine the new value of a cell based on its adjacent cells (or even state of the whole grid).

Implementations

impl Grid[src]

pub fn new(h_size: u8, v_size: u8) -> Grid[src]

Create a new grid with the given dimensions and fill it with default (dead) cells.

Arguments

  • h_size: horizontal dimension/size as number of cells
  • v_size: vertical dimension/size as number of cells

Remarks

u8 was chosen to stay below usize::MAX for a u8 x u8 grid. 256x256 are currently enough cells for embedded applications. Larger grid sizes have to keep the target usize (thus architecture) in mind and can be adjusted appropriately.

pub fn get_horizontal_size(&self) -> u8[src]

Get the number of columns (i.e. horizontal size)

pub fn get_vertical_size(&self) -> u8[src]

Get number of rows (i.e. vertical size)

pub fn get_cellstate(&self, h: u8, v: u8) -> &CellState[src]

Retrieve a cell state (for modification).

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn get_cellstate_hv(&self, hv: (u8, u8)) -> &CellState[src]

Retrieve a cell state (for modification) using a coordinate tuple.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

pub fn set_cellstate(&mut self, h: u8, v: u8, state: CellState)[src]

Set a (modified) cell state.

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn set_cellstate_hv(&mut self, hv: (u8, u8), state: CellState)[src]

Set a (modified) cell state using a coordination tuple.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

pub fn get_north_coordinate(&self, h: u8, v: u8) -> (u8, u8)[src]

Get coordinates of "northern" cell relative to the given grid coordinates.

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn get_north_coordinate_hv(&self, hv: (u8, u8)) -> (u8, u8)[src]

Get coordinates of "northern" cell relative to the given grid coordinates.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

pub fn get_east_coordinate(&self, h: u8, v: u8) -> (u8, u8)[src]

Get coordinates of "eastern" cell relative to the given grid coordinates.

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn get_east_coordinate_hv(&self, hv: (u8, u8)) -> (u8, u8)[src]

Get coordinates of "eastern" cell relative to the given grid coordinates.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

pub fn get_south_coordinate(&self, h: u8, v: u8) -> (u8, u8)[src]

Get coordinates of "southern" cell relative to the given grid coordinates.

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn get_south_coordinate_hv(&self, hv: (u8, u8)) -> (u8, u8)[src]

Get coordinates of "eastern" cell relative to the given grid coordinates.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

pub fn get_west_coordinate(&self, h: u8, v: u8) -> (u8, u8)[src]

Get coordinates of "western" cell relative to the given grid coordinates.

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn get_west_coordinate_hv(&self, hv: (u8, u8)) -> (u8, u8)[src]

Get coordinates of "western" cell relative to the given grid coordinates.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

pub fn get_northeast_coordinate(&self, h: u8, v: u8) -> (u8, u8)[src]

Get coordinates of "north eastern" cell relative to the given grid coordinates.

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn get_northeast_coordinate_hv(&self, hv: (u8, u8)) -> (u8, u8)[src]

Get coordinates of "north eastern" cell relative to the given grid coordinates.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

pub fn get_southeast_coordinate(&self, h: u8, v: u8) -> (u8, u8)[src]

Get coordinates of "south eastern" cell relative to the given grid coordinates.

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn get_southeast_coordinate_hv(&self, hv: (u8, u8)) -> (u8, u8)[src]

Get coordinates of "south eastern" cell relative to the given grid coordinates.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

pub fn get_southwest_coordinate(&self, h: u8, v: u8) -> (u8, u8)[src]

Get coordinates of "south western" cell relative to the given grid coordinates.

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn get_southwest_coordinate_hv(&self, hv: (u8, u8)) -> (u8, u8)[src]

Get coordinates of "south western" cell relative to the given grid coordinates.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

pub fn get_northwest_coordinate(&self, h: u8, v: u8) -> (u8, u8)[src]

Get coordinates of "north western" cell relative to the given grid coordinates.

Arguments

  • h: horizontal coordinate
  • v: vertical coordinate

pub fn get_northwest_coordinate_hv(&self, hv: (u8, u8)) -> (u8, u8)[src]

Get coordinates of "north western" cell relative to the given grid coordinates.

Arguments

  • hv: tuple (horizontal coordinate, vertical coordinate)

Trait Implementations

impl Clone for Grid[src]

impl Copy for Grid[src]

impl Debug for Grid[src]

Auto Trait Implementations

impl Send for Grid[src]

impl Sync for Grid[src]

impl Unpin for Grid[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.