[−][src]Struct rate_common::literal::Literal
A literal, encoded as 32 bit unsigned integer.
Fields
encoding: u32
We use a sign-magnitude encoding (also used by AIGER and others). This allows us to directly use this as offset.
- The least significant bit is the sign (negative if it is 1).
- The remaining bits encode the variable.
Methods
impl Literal
[src]
pub fn new(value: i32) -> Literal
[src]
Create a literal from the signed representation used in DIMACS.
pub const fn from_raw(encoding: u32) -> Literal
[src]
Create a literal without conversion.
pub const TOP: Literal
[src]
Encoded as 0.
pub const BOTTOM: Literal
[src]
Encoded as 1.
pub const NEVER_READ: Literal
[src]
Sentinel value of u32::max_value()
to detect errors.
pub fn decode(self) -> i32
[src]
DIMACS representation.
Examples
use rate_common::literal::Literal; assert_eq!(Literal::new(-1).decode(), -1);
pub const fn variable(self) -> Variable
[src]
Examples
use rate_common::literal::{Literal, Variable}; assert_eq!(Literal::new(-3).variable(), Variable(3));
pub fn is_constant(self) -> bool
[src]
True if it is Literal::TOP
or Literal::BOTTOM
.
Examples
use rate_common::literal::Literal; assert!(Literal::TOP.is_constant()); assert!(!Literal::new(-3).is_constant());
pub fn all(maxvar: Variable) -> impl Iterator<Item = Literal>
[src]
Produce all literals from 1 and -1 up to the given variable.
Examples
use rate_common::literal::{Literal, Variable}; assert_eq!(Literal::all(Variable(2)).collect::<Vec<_>>(), vec!(Literal::new(1), Literal::new(-1), Literal::new(2), Literal::new(-2)));
pub const fn is_zero(self) -> bool
[src]
Examples
use rate_common::literal::Literal; assert!(Literal::new(0).is_zero()); assert!(!Literal::new(1).is_zero());
Trait Implementations
impl Offset for Literal
[src]
Enable as array index.
impl Clone for Literal
[src]
impl Copy for Literal
[src]
impl Default for Literal
[src]
impl Eq for Literal
[src]
impl Ord for Literal
[src]
fn cmp(&self, other: &Literal) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Literal> for Literal
[src]
impl PartialOrd<Literal> for Literal
[src]
fn partial_cmp(&self, other: &Literal) -> Option<Ordering>
[src]
fn lt(&self, other: &Literal) -> bool
[src]
fn le(&self, other: &Literal) -> bool
[src]
fn gt(&self, other: &Literal) -> bool
[src]
fn ge(&self, other: &Literal) -> bool
[src]
impl Display for Literal
[src]
Examples
use rate_common::literal::Literal; assert_eq!(format!("{}", Literal::TOP), "+0"); assert_eq!(format!("{}", Literal::BOTTOM), "-0"); assert_eq!(format!("{}", Literal::new(11)), "11");
impl Debug for Literal
[src]
impl Neg for Literal
[src]
Negate a literal with operator -
.
Examples
use rate_common::literal::Literal; assert!(-Literal::TOP == Literal::BOTTOM);
impl Index<Literal> for Assignment
[src]
type Output = bool
The returned type after indexing.
fn index(&self, literal: Literal) -> &bool
[src]
This assumes that we don't ever pass a constant literal, however this can be changed if necessary.
impl Hash for Literal
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Serialize for Literal
[src]
impl<'de> Deserialize<'de> for Literal
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Auto Trait Implementations
impl Send for Literal
impl Sync for Literal
impl Unpin for Literal
impl UnwindSafe for Literal
impl RefUnwindSafe for Literal
Blanket Implementations
impl<T> HeapSpace for T where
T: Copy,
[src]
T: Copy,
fn heap_space(&Self) -> usize
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,