NQueens

Struct NQueens 

Source
pub struct NQueens {
    pub possibilities: Vec<Possibility>,
    pub constraints: Vec<Constraint>,
    pub side_length: usize,
}
Expand description

An instance of the n queens problem.

Fields§

§possibilities: Vec<Possibility>

The list of possible positions that could solve the n queens puzzle.

§constraints: Vec<Constraint>

The list of constraints that must be satisfied for this n queens puzzle.

§side_length: usize

The length of the chess board side, equal to n.

Implementations§

Source§

impl NQueens

Source

pub fn new( side_length: usize, filled_values: impl IntoIterator<Item = Possibility>, ) -> Self

Create a new instance of the n queens problem with the given filled values and side length.

Trait Implementations§

Source§

impl Debug for NQueens

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ExactCover for NQueens

Source§

type Constraint = Constraint

The type of value that are constraints on a given instance of an exact cover problem.
Source§

type Possibility = Possibility

The type of values that are elements of a solution to the exact cover problem.
Source§

fn satisfies(&self, poss: &Self::Possibility, cons: &Self::Constraint) -> bool

Return true if the given Possibility will satisfy the given Constraint.
Source§

fn is_optional(&self, cons: &Self::Constraint) -> bool

Return true if the given Constraint is optional.
Source§

fn possibilities(&self) -> &[Self::Possibility]

Return a list of possibilities for this instance of the problem.
Source§

fn constraints(&self) -> &[Self::Constraint]

Return a list of constraints that must be satisfied for this instance of the problem.
Source§

fn solver(&self) -> Solver<'_, Self>
where Self: Sized,

Return an iterator over all solutions to this instance of the exact cover problem.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.