pub struct Table { /* private fields */ }Expand description
The variables take one of the listed tuples of values.
Any relation over a few variables can be written this way: a KenKen cage (every tuple with the right sum or product), the allowed colour pairs of two regions, the shifts a worker can take on consecutive days. Propagation is complete: afterwards every value left is part of an allowed tuple whose other values are all still possible. Each run scans the tuples once.
§Examples
use constraint_search::{Domain, Domains, Propagator, Table};
let mut domains = Domains::<u16>::new();
let x = domains.add(u16::range(4));
let y = domains.add(u16::range(4));
// A two-cell cage whose values sum to 5.
let cage = Table::new([x, y], [[2, 3], [3, 2]]);
cage.propagate(&mut domains, &mut Vec::new())?;
assert!(domains[x].values().eq([2, 3]));Implementations§
Source§impl Table
impl Table
Sourcepub fn new<T: AsRef<[u32]>>(
vars: impl IntoIterator<Item = Var>,
tuples: impl IntoIterator<Item = T>,
) -> Self
pub fn new<T: AsRef<[u32]>>( vars: impl IntoIterator<Item = Var>, tuples: impl IntoIterator<Item = T>, ) -> Self
The constraint that vars take one of tuples, each listing one value per variable.
§Panics
Panics if vars is empty, holds a variable twice, or if a tuple’s length differs from
the number of variables.
Trait Implementations§
impl Eq for Table
Source§impl<D: Domain> Propagator<D> for Table
impl<D: Domain> Propagator<D> for Table
impl StructuralPartialEq for Table
Auto Trait Implementations§
impl Forget for Table
impl Freeze for Table
impl Move for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
impl UnwindSafe for Table
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more