Struct HashMapAssignment

Source
pub struct HashMapAssignment { /* private fields */ }
Expand description

An implementation of Assignment using an FxHashMap<Variable, VarState>.

This implementation is suitable for sparse sets of variables or when variable IDs are not necessarily small or contiguous. It stores states only for variables that have been explicitly set or unassigned. Accessing a variable not in the map via Index will return VarState::Unassigned.

Trait Implementations§

Source§

impl Assignment for HashMapAssignment

Source§

fn new(n_vars: usize) -> Self

Creates a new HashMapAssignment.

§Arguments
  • n_vars: The conceptual number of variables. This is used by all_assigned to determine if all expected variables have assignments, and by unassigned to iterate up to this many variables.
Source§

fn unassign(&mut self, var: Variable)

Unassigns a variable by setting its state to VarState::Unassigned in the map. If the variable was not in the map, it will be inserted as Unassigned.

Source§

fn num_vars(&self) -> usize

Returns the total number of variables this assignment manager is configured for.
Source§

fn set(&mut self, var: Variable, b: bool)

Sets the truth value of a variable. Read more
Source§

fn reset(&mut self)

Resets all variables to the Unassigned state.
Source§

fn get_solutions(&self) -> Solutions

Retrieves the current set of assigned variables as a Solutions object. Read more
Source§

fn all_assigned(&self) -> bool

Checks if all variables managed by this assignment are currently assigned. Read more
Source§

fn assign(&mut self, l: impl Literal)

Assigns a truth value to a variable based on a literal. Read more
Source§

fn is_assigned(&self, var: Variable) -> bool

Checks if a specific variable is assigned a truth value. Read more
Source§

fn var_value(&self, var: Variable) -> Option<bool>

Gets the truth value of a variable, if assigned. Read more
Source§

fn literal_value(&self, l: impl Literal) -> Option<bool>

Gets the truth value of a literal under the current assignment. Read more
Source§

fn unassigned(&self) -> impl Iterator<Item = Variable> + '_

Returns an iterator over all currently unassigned variables. Read more
Source§

impl Clone for HashMapAssignment

Source§

fn clone(&self) -> HashMapAssignment

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HashMapAssignment

Source§

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

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

impl Default for HashMapAssignment

Source§

fn default() -> HashMapAssignment

Returns the “default value” for a type. Read more
Source§

impl Index<usize> for HashMapAssignment

Source§

fn index(&self, index: usize) -> &Self::Output

Accesses the state of the variable corresponding to index.

If the variable (converted from index) is not in the map, it’s treated as Unassigned.

Source§

type Output = VarState

The returned type after indexing.
Source§

impl IndexMut<usize> for HashMapAssignment

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Mutably accesses the state of the variable corresponding to index.

If the variable (converted from index) is not in the map, it’s inserted with VarState::Unassigned before returning a mutable reference.

Source§

impl PartialEq for HashMapAssignment

Source§

fn eq(&self, other: &HashMapAssignment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for HashMapAssignment

Source§

impl StructuralPartialEq for HashMapAssignment

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.