[−][src]Struct connect6::game::Block
Swapable two Cumulative arrays for dynamic programming
flag
represent index of previous arrays.
Method swap can be implemented as just flip the flag bit.
Methods
impl Block
[src]
pub fn new() -> Block
[src]
Construct a new Block.
pub fn as_tuple(&self) -> (&[Cumulative; 17], &[Cumulative; 17])
[src]
Get a tuple representation of block, (prev, current).
pub fn get_prev(&self, col: usize, path: &Path) -> &Cumulative
[src]
Get a previous Cumulative
cell for specific direction.
If right direction is given, left cell of current column is return, if down direction is given, upper cell of current column is return, if left_down direction is given, upper-right cell of current column is return, if right_down direction is given, upper-left cell of current column is return.
Examples
let block = Block::new(); let (prev, current) = block.as_tuple(); let result = block.get_prev(1, &Path::Right); assert_eq!(*result, current[0]);
pub fn update_now<F>(&mut self, update: F) where
F: Fn(&mut [Cumulative; 17]),
[src]
F: Fn(&mut [Cumulative; 17]),
Update current row with given update rule
Examples
let mut block = Block::new(); block.update_now(|row| row.iter_mut().for_each(|c| *c.get_mut(&Path::Right) = 1));
pub fn update_row(&mut self)
[src]
Swap the row and clear the current.
Examples
let mut block = Block::new(); let current_backup = { let (_, current) = block.as_tuple(); *current }; block.update_row(); let (prev, current) = block.as_tuple(); assert_eq!(*prev, current_backup); assert_eq!(*current, [Cumulative::new(); BOARD_SIZE+2]);
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,