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 clear_log(&mut self)
pub fn clear_log(&mut self)
Drop the undo log without touching the working domain.
Used by the restart driver to bake a post-propagation “baseline”
domain in place: the reductions already applied to domain are kept,
but their depth-tagged log entries are discarded so subsequent
restore() calls at any search depth cannot un-prune them. This is
the seam fix that stops a depth-0 backtrack from silently undoing
solve_with_given’s initial AC-3.
Sourcepub fn reset_to(&mut self, domain: D)
pub fn reset_to(&mut self, domain: D)
Reset the working domain to domain and clear the undo log.
The restart driver calls this to return every variable to the shared post-initial-propagation baseline before re-descending.
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.