BitBoard

Trait BitBoard 

Source
pub trait BitBoard: Sized {
Show 18 methods // Required methods fn n_rows(&self) -> usize; fn n_cols(&self) -> usize; fn board_mut(&mut self) -> &mut BitSlice ; fn board(&self) -> &BitSlice ; fn or(&self, other: &impl BitBoard) -> Result<Self, DimensionMismatch>; fn and(&self, other: &impl BitBoard) -> Result<Self, DimensionMismatch>; // Provided methods fn index_of(&self, row: usize, col: usize) -> usize { ... } fn row_col_of(&self, index: usize) -> (usize, usize) { ... } fn fill(&mut self, value: bool) { ... } fn set(&mut self, row: usize, col: usize, value: bool) { ... } fn get(&self, row: usize, col: usize) -> bool { ... } fn set_col(&mut self, col: usize, value: bool) { ... } fn get_col(&self, col: usize) -> impl Iterator<Item = bool> { ... } fn set_row(&mut self, row: usize, value: bool) { ... } fn get_row(&self, row: usize) -> impl Iterator<Item = bool> { ... } fn set_cardinal_neighbors(&mut self, row: usize, col: usize, value: bool) { ... } fn set_diagonals(&mut self, row: usize, col: usize, value: bool) { ... } fn set_all_neighbors(&mut self, row: usize, col: usize, value: bool) { ... }
}

Required Methods§

Source

fn n_rows(&self) -> usize

Returns the number of rows in the board.

Source

fn n_cols(&self) -> usize

Returns the number of columns in the board.

Source

fn board_mut(&mut self) -> &mut BitSlice

Returns a mutable reference to the underlying bits.

Source

fn board(&self) -> &BitSlice

Returns an immutable reference to the underlying bits.

Source

fn or(&self, other: &impl BitBoard) -> Result<Self, DimensionMismatch>

Source

fn and(&self, other: &impl BitBoard) -> Result<Self, DimensionMismatch>

Provided Methods§

Source

fn index_of(&self, row: usize, col: usize) -> usize

Get the index that we can use to directly access a certain spot on the board

Source

fn row_col_of(&self, index: usize) -> (usize, usize)

Get the row and column of the linear index

Source

fn fill(&mut self, value: bool)

Set all bits to the desired value.

Source

fn set(&mut self, row: usize, col: usize, value: bool)

Set the value at index [row, col] to be the new_val.

Source

fn get(&self, row: usize, col: usize) -> bool

Get the value at index [row, col]. If the index is out of bounds, return false.

Source

fn set_col(&mut self, col: usize, value: bool)

Set an entire column to a certain value

Source

fn get_col(&self, col: usize) -> impl Iterator<Item = bool>

Get the values in a given col

Source

fn set_row(&mut self, row: usize, value: bool)

Set an entire row to a certain value

Source

fn get_row(&self, row: usize) -> impl Iterator<Item = bool>

Get the values in a given row

Source

fn set_cardinal_neighbors(&mut self, row: usize, col: usize, value: bool)

Will set the neighbors immediately above, below, left, and right to value. If the neighbor is out of bounds, nothing will happen

Source

fn set_diagonals(&mut self, row: usize, col: usize, value: bool)

Set just the spots diagonal from the given position to value. If the neighbor is out of bounds, nothing will happen

Source

fn set_all_neighbors(&mut self, row: usize, col: usize, value: bool)

Set the cardinal neighbors and the diagonal neighbors to value. If the neighbor is out of bounds, nothing will happen

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§