Struct sudoku_variants::solver::strategy::SudokuInfo [−][src]
Enriches a Sudoku with additional information about which numbers can go into the cells. This is analogous to the pencil markings a human player would make. It is used by Strategies to communicate the results of logical reasoning.
This struct already excludes options which violate the Sudoku’s constraint, unless unprocessed changes have been made.
Implementations
impl<C: Constraint + Clone> SudokuInfo<C>
[src]
pub fn from_sudoku(sudoku: Sudoku<C>) -> SudokuInfo<C>
[src]
Creates a new Sudok info for a Sudoku. The options for all cells that are empty in the provided Sudoku are all valid digits, and the options for cells which are filled in the Sudoku are only the digit in that cell.
pub fn get_cell(&self, column: usize, row: usize) -> SudokuResult<Option<usize>>
[src]
Gets the content of the cell at the specified position.
This is syntactic sugar for x.sudoku().grid().get_cell(...)
.
Arguments
column
: The column (x-coordinate) of the desired cell. Must be in the range[0, size[
.row
: The row (y-coordinate) of the desired cell. Must be in the range[0, size[
.
Errors
If either column
or row
are not in the specified range. In that
case, SudokuError::OutOfBounds
is returned.
pub fn enqueue_enter_cell(
&mut self,
column: usize,
row: usize,
number: usize
) -> SudokuResult<()>
[src]
&mut self,
column: usize,
row: usize,
number: usize
) -> SudokuResult<()>
Enqueues a number to be assigned to the content of the cell at the specified position on the next update. If the cell is not empty at that point, the old number will be overwritten.
In contrast with enter_cell_no_update, this function never enters the number into the cell right away, so when querying the cell it will still look empty. This is done both for performance reasons and to preserve semantics of only applying a strategy once for strategies which may process the same cell more than once, which is important for the bounded backtracking strategies. To ensure that the state of this is up-to-date, i.e. the new cells are entered and the options are adapted to accomodate for them, call invalidate after you are finished enqueueing changes.
Arguments
column
: The column (x-coordinate) of the assigned cell. Must be in the range[0, size[
.row
: The row (y-coordinate) of the assigned cell. Must be in the range[0, size[
.number
: The number to assign to the specified cell. Must be in the range[1, size]
.
Errors
SudokuError::OutOfBounds
If eithercolumn
orrow
are not in the specified range.SudokuError::InvalidNumber
Ifnumber
is not in the specified range.
pub fn enter_cell_no_update(
&mut self,
column: usize,
row: usize,
number: usize
) -> SudokuResult<()>
[src]
&mut self,
column: usize,
row: usize,
number: usize
) -> SudokuResult<()>
Sets the content of the cell at the specified position to the given number. If the cell was not empty, the old number will be overwritten.
In contrast with enter_cell, this method does not remove cell options that are invalidated by the new digit. This is done for performance reasons to allow batching of multiple changes before updating the options. To ensure the cell options are up-to-date, call invalidate after making any changes.
Arguments
column
: The column (x-coordinate) of the assigned cell. Must be in the range[0, size[
.row
: The row (y-coordinate) of the assigned cell. Must be in the range[0, size[
.number
: The number to assign to the specified cell. Must be in the range[1, size]
.
Errors
SudokuError::OutOfBounds
If eithercolumn
orrow
are not in the specified range.SudokuError::InvalidNumber
Ifnumber
is not in the specified range.
pub fn enter_cell(
&mut self,
column: usize,
row: usize,
number: usize
) -> SudokuResult<()>
[src]
&mut self,
column: usize,
row: usize,
number: usize
) -> SudokuResult<()>
Sets the content of the cell at the specified position to the given number. If the cell was not empty, the old number will be overwritten.
In contrast with enter_cell_no_update, this method immediately removes all cell options that are invalidated by the new digit.
Arguments
column
: The column (x-coordinate) of the assigned cell. Must be in the range[0, size[
.row
: The row (y-coordinate) of the assigned cell. Must be in the range[0, size[
.number
: The number to assign to the specified cell. Must be in the range[1, size]
.
Errors
SudokuError::OutOfBounds
If eithercolumn
orrow
are not in the specified range.SudokuError::InvalidNumber
Ifnumber
is not in the specified range.
pub fn invalidate(&mut self)
[src]
Removes all cell options that have been invalidated by digits entered using enter_cell_no_update which have not yet been processed. If there are no pending digits, nothing will be done.
pub fn get_options(&self, column: usize, row: usize) -> SudokuResult<&USizeSet>
[src]
Gets a USizeSet of the possible digits that can be entered into the cell at the given position according to this grid info.
Note that, because options are adapted to new digits lazily, this
operation may require changes to this instance, namely if digits were
changed since the last call to get_options
or get_options_mut
. This
means a mutable reference to this instance is required.
Arguments
column
: The column (x-coordinate) of the desired cell. Must be in the range[0, size[
.row
: The row (y-coordinate) of the desired cell. Must be in the range[0, size[
.
Errors
If either column
or row
are not in the specified range. In that
case, SudokuError::OutOfBounds
is returned.
pub fn get_options_mut(
&mut self,
column: usize,
row: usize
) -> SudokuResult<&mut USizeSet>
[src]
&mut self,
column: usize,
row: usize
) -> SudokuResult<&mut USizeSet>
Gets a mutable reference to the USizeSet that tracks the possible digits that can be entered into the cell at the given position according to this grid info.
Note that, because options are adapted to new digits lazily, this
operation may require changes to this instance, namely if digits were
changed since the last call to get_options
or get_options_mut
.
Arguments
column
: The column (x-coordinate) of the desired cell. Must be in the range[0, size[
.row
: The row (y-coordinate) of the desired cell. Must be in the range[0, size[
.
Errors
If either column
or row
are not in the specified range. In that
case, SudokuError::OutOfBounds
is returned.
pub fn size(&self) -> usize
[src]
Gets the total size of the grid for which this instance tracks information on one axis (horizontally or vertically). Since grids are always squares, this is guaranteed to be valid for both axes.
pub fn cell_options(&self) -> &Vec<USizeSet>
[src]
Gets a read-only reference to the vector storing the options for every cell in a USizeSet. The cells are in eft-to-right, top-to-bottom order, where rows are together.
pub fn cell_options_mut(&mut self) -> &mut Vec<USizeSet>
[src]
Gets a mutable reference to the vector storing the options for every cell in a USizeSet. The cells are in left-to-right, top-to-bottom order, where rows are together.
pub fn block_width(&self) -> usize
[src]
Gets the width (number of columns) of one sub-block of the Sudoku. To ensure a square grid, this is also the number of blocks that compose the grid vertically.
This is syntactic sugar for x.sudoku().grid().block_width()
.
pub fn block_height(&self) -> usize
[src]
Gets the height (number of rows) of one sub-block of the Sudoku. To ensure a square grid, this is also the number of blocks that compose the grid horizontally.
This is syntactic sugar for x.sudoku().grid().block_height()
.
pub fn assign(&mut self, other: &SudokuInfo<C>) -> SudokuResult<()>
[src]
Assigns the content of another grid info to this one, that is, after
the operation this grid info will equal other
. The dimensions must be
equivalent.
Errors
If other
has different dimensions to this instance. In that case,
SudokuError::InvalidDimensions
is returned.
pub fn sudoku(&self) -> &Sudoku<C>
[src]
Gets the Sudoku for which this Sudoku info stores additional information.
pub fn sudoku_mut(&mut self) -> &mut Sudoku<C>
[src]
Gets a mutable reference to the Sudoku for which this Sudoku info stores additional information.
pub fn intersect_assign(&mut self, other: &SudokuInfo<C>) -> SudokuResult<bool>
[src]
Intersects this Sudoku info with the given other one, implying that all information of both is correct. All cells that are filled in in either will be written in the result and only options that are present in both will be retained. Note that contradictions (different digits in this and the other Sudoku info) will result in the cell being cleared and all options being removed.
pub fn union_assign(&mut self, other: &SudokuInfo<C>) -> SudokuResult<bool>
[src]
Unifies this Sudoku info with the given other one, implying that all information of both could be correct. Options present in at least one will be put in the result and digits are only retained if they are present in both (unless the other does not have any options for that cell). Note that contradictions (different digits in this and the other Sudoku info) will result in the cell being cleared and both numbers being put in the option set.
Trait Implementations
impl<C: Clone + Constraint> Clone for SudokuInfo<C>
[src]
fn clone(&self) -> SudokuInfo<C>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<C: Constraint + Clone> PartialEq<SudokuInfo<C>> for SudokuInfo<C>
[src]
Auto Trait Implementations
impl<C> RefUnwindSafe for SudokuInfo<C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
impl<C> Send for SudokuInfo<C> where
C: Send,
C: Send,
impl<C> Sync for SudokuInfo<C> where
C: Sync,
C: Sync,
impl<C> Unpin for SudokuInfo<C> where
C: Unpin,
C: Unpin,
impl<C> UnwindSafe for SudokuInfo<C> where
C: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,