[][src]Struct connect6::game::Block

pub struct Block { /* fields omitted */ }

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]

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

impl Send for Block

impl Sync for Block

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

impl<T> Erased for T