pub struct Clause { /* private fields */ }Expand description
Type representing a clause. Wrapper around a std collection to allow for changing the data structure. Optional clauses as sets will be included in the future.
Implementations§
Source§impl Clause
impl Clause
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new empty clause with at least the specified capacity.
Uses Vec::with_capacity internally.
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more literals.
Uses Vec::reserve internally.
Sourcepub fn reserve_exact(&mut self, additional: usize)
pub fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for at least additional more literals.
Uses Vec::reserve_exact internally.
Sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional more literals.
Uses Vec::try_reserve internally.
§Errors
If the capacity overflows, or the allocator reports a failure, then an error is returned.
Sourcepub fn try_reserve_exact(
&mut self,
additional: usize,
) -> Result<(), TryReserveError>
pub fn try_reserve_exact( &mut self, additional: usize, ) -> Result<(), TryReserveError>
Tries to reserve the minimum capacity for at least additional more literals.
Uses Vec::try_reserve_exact internally.
§Errors
If the capacity overflows, or the allocator reports a failure, then an error is returned.
Sourcepub fn drain<R: RangeBounds<usize>>(&mut self, range: R) -> Drain<'_, Lit>
pub fn drain<R: RangeBounds<usize>>(&mut self, range: R) -> Drain<'_, Lit>
Like Vec::drain
Sourcepub fn normalize(self) -> Option<Self>
pub fn normalize(self) -> Option<Self>
Normalizes the clause. This includes sorting the literals, removing duplicates and removing the entire clause if it is a tautology. Comparing two normalized clauses checks their logical equivalence.
Sourcepub fn sanitize(self) -> Option<Self>
pub fn sanitize(self) -> Option<Self>
Sanitizes the clause. This includes removing duplicates and removing the entire clause if it is a tautology. This preserves the order of the literals in the clause.
Sourcepub fn remove(&mut self, lit: Lit) -> bool
pub fn remove(&mut self, lit: Lit) -> bool
Removes the first occurrence of a literal from the clause Returns true if an occurrence was found
Sourcepub fn remove_thorough(&mut self, lit: Lit) -> bool
pub fn remove_thorough(&mut self, lit: Lit) -> bool
Removes all occurrences of a literal from the clause
Methods from Deref<Target = Cl>§
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Lit>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Lit>
Gets a mutable iterator over the clause
Sourcepub fn evaluate(&self, assignment: &Assignment) -> TernaryVal
pub fn evaluate(&self, assignment: &Assignment) -> TernaryVal
Evaluates a clause under a given assignment
Sourcepub fn is_tautology(&self) -> bool
pub fn is_tautology(&self) -> bool
Checks whether the clause is tautological
Sourcepub fn sort(&mut self)
pub fn sort(&mut self)
Performs slice::sort_unstable on the clause
Trait Implementations§
Source§impl ConstraintLike<Var> for Clause
Available on crate feature proof-logging only.
impl ConstraintLike<Var> for Clause
proof-logging only.Source§impl<'de> Deserialize<'de> for Clause
impl<'de> Deserialize<'de> for Clause
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'a> Extend<&'a Clause> for Solver
impl<'a> Extend<&'a Clause> for Solver
Source§fn extend<T: IntoIterator<Item = &'a Clause>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = &'a Clause>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<Clause> for Cnf
impl Extend<Clause> for Cnf
Source§fn extend<Iter: IntoIterator<Item = Clause>>(&mut self, iter: Iter)
fn extend<Iter: IntoIterator<Item = Clause>>(&mut self, iter: Iter)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<Clause> for Solver
impl Extend<Clause> for Solver
Source§fn extend<T: IntoIterator<Item = Clause>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Clause>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<Lit> for Clause
impl Extend<Lit> for Clause
Source§fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<Clause> for CardConstraint
impl From<Clause> for CardConstraint
Source§impl From<Clause> for PbConstraint
impl From<Clause> for PbConstraint
Source§impl FromIterator<Clause> for Cnf
impl FromIterator<Clause> for Cnf
Source§impl<VM: ManageVars + Default> FromIterator<Clause> for Instance<VM>
impl<VM: ManageVars + Default> FromIterator<Clause> for Instance<VM>
Source§impl FromIterator<Lit> for Clause
impl FromIterator<Lit> for Clause
Source§impl<'a> IntoIterator for &'a Clause
impl<'a> IntoIterator for &'a Clause
Source§impl<'a> IntoIterator for &'a mut Clause
impl<'a> IntoIterator for &'a mut Clause
Source§impl IntoIterator for Clause
impl IntoIterator for Clause
Source§impl Ord for Clause
impl Ord for Clause
Source§impl PartialOrd for Clause
impl PartialOrd for Clause
impl Eq for Clause
impl StructuralPartialEq for Clause
Auto Trait Implementations§
impl Freeze for Clause
impl RefUnwindSafe for Clause
impl Send for Clause
impl Sync for Clause
impl Unpin for Clause
impl UnwindSafe for Clause
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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