Skip to main content

Assignment

Struct Assignment 

Source
pub struct Assignment<V> {
    pub assignment: Vec<V>,
}
Expand description

Data structure to store mapping from VarIdx to VarType.

Fields§

§assignment: Vec<V>

Implementations§

Source§

impl<V> Assignment<V>
where V: VarType,

Source

pub fn with_size(size: usize) -> Self

Initialize a new Assignment with specific size where all entries are set to the default value of VarType.

Source

pub fn resize(&mut self, new_len: usize)

Resizes the Assignment to the given new_len.

If new_len is smaller than the current len of Assignment, the Assignment is truncated to new_len. If new_len is larger than the current len of Assignment, then Assignment is increased up to new_len and filled with the default values for VarType, but the entries up to the current length are left unchanged.

Source

pub fn set_value(&mut self, idx: VarIdx, value: V::Value)

Set variable at index idx to value.

Source

pub fn get_value(&self, idx: VarIdx) -> V::Value

Get the value of the variable at index idx.

Source

pub fn set_lit_value(&mut self, lit: Lit, value: V::Value)

Set a value by using a Lit. Hence, if Lit is negated, then the value assigned to its variable is negated.

Source

pub unsafe fn set_lit_value_unchecked(&mut self, lit: Lit, value: V::Value)

Set a value by literal. Hence, if the literal is negated, then value assigned to its variable is negated.

§Safety

The caller must ensure that the Assignment has a large enough size, so that the variable index of lit is at most that size.

Using a lit with variable index of at least the size of Assignment is undefined behaviour.

Source

pub fn get_lit_value(&self, lit: Lit) -> V::Value

Get the value of a Lit. Hence, if Lit is negated, then value assigned to its variable is negated.

Source

pub unsafe fn get_lit_value_unchecked(&self, lit: Lit) -> V::Value

Same as get_lit_value but without bounds check.

§Safety

The caller must ensure that the Assignment has a large enough size, so that the variable index of lit is at most that size.

Using a lit with variable index of at least the size of Assignment is undefined behaviour.

Source

pub fn reset(&mut self)

Reset the Assignment to its default values.

Source

pub fn len(&self) -> usize

Returns the number of variables in the Assignment no matter their value.

Source

pub fn is_empty(&self) -> bool

Returns true if the assignment is empty, i.e., it contains no variables, neither unassigned nor assigned.

Source§

impl Assignment<BooleanVar>

Source

pub fn from(literals: &Vec<Lit>) -> Option<Self>

Create an Assignment from a Vec<Lit>.

Returns Some(assignment) if the literals are consistent, i.e., Vec<Lit> does not contain a literal and its negation. If literals is not consistent, then None is returned.

Source

pub fn is_unassigned(&self, var: VarIdx) -> bool

Test if the variable is unassigned.

Returns true if the variable matches BoolValue::Unassigned.

Source

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

Test if the variable is assigned to some value.

Returns true if the variable matches BoolValue::Assigned(_).

Trait Implementations§

Source§

impl<V: Clone> Clone for Assignment<V>

Source§

fn clone(&self) -> Assignment<V>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for Assignment<V>

Source§

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

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

impl<V: Default> Default for Assignment<V>

Source§

fn default() -> Assignment<V>

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

impl Display for Assignment<BooleanVar>

Source§

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

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

impl Substitutable for Assignment<BooleanVar>

Source§

fn get_lit(&self, lit: Lit) -> Option<SubstitutionValue>

Get the SubstitutionValue that lit is mapped to. Read more
Source§

impl ToPrettyString for Assignment<BooleanVar>

Source§

fn to_pretty_string(&self, var_names: &VarNameManager) -> String

Format to a string using the correct variable names.

Auto Trait Implementations§

§

impl<V> Freeze for Assignment<V>

§

impl<V> RefUnwindSafe for Assignment<V>
where V: RefUnwindSafe,

§

impl<V> Send for Assignment<V>
where V: Send,

§

impl<V> Sync for Assignment<V>
where V: Sync,

§

impl<V> Unpin for Assignment<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for Assignment<V>

§

impl<V> UnwindSafe for Assignment<V>
where V: UnwindSafe,

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, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Enum> FromEnum<Enum> for Enum

Source§

fn from_enum(e: Enum) -> Result<Enum, Enum>

The inverse of EnumExtensions::try_into_var, see that method’s documentation for more. Read more
Source§

impl<Enum> FromEnumMut<Enum> for Enum

Source§

fn from_enum_mut(e: &mut Enum) -> Option<&mut Enum>

The inverse of EnumExtensions::try_mut_var, see that method’s documentation for more. Read more
Source§

impl<Enum> FromEnumRef<Enum> for Enum

Source§

fn from_enum_ref(e: &Enum) -> Option<&Enum>

The inverse of EnumExtensions::try_ref_var, see that method’s documentation for more. Read more
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, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U