pub struct Variable<D: Domain> {
pub domain: D,
/* private fields */
}Expand description
A CSP variable holding its current domain and an undo log for backtracking.
Fields§
§domain: DCurrent (working) domain – mutated during search.
Implementations§
Source§impl<D: Domain> Variable<D>
impl<D: Domain> Variable<D>
Sourcepub fn prune(&mut self, val: &D::Value, depth: usize) -> bool
pub fn prune(&mut self, val: &D::Value, depth: usize) -> bool
Record that val was pruned at depth, and remove it from the domain.
Returns true if the value was actually present and removed.
Sourcepub fn set_domain(&mut self, domain: D)
pub fn set_domain(&mut self, domain: D)
Replace the current domain entirely (used during initial propagation).
Sourcepub fn restrict_to(&mut self, val: &D::Value, depth: usize)
pub fn restrict_to(&mut self, val: &D::Value, depth: usize)
Restrict domain to a single value, recording all other removals at depth.
This is the fast path for backtracking assignment — avoids collecting
domain values into a Vec just to prune them.
Delegates the actual domain mutation to Domain::restrict_to, which
for BitsetDomain clears every bit but val’s in one bitwise AND
(O(1)) instead of this method’s previous per-value iterate-and-remove
loop (O(domain size) bit ops, on top of the Vec collect it used to
allocate). This method’s own job shrinks to what only it can do:
recording each removed value on the depth-keyed undo log.