[][src]Struct rate_common::literal::Literal

pub struct Literal {
    pub encoding: u32,
}

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]

impl PartialEq<Literal> for Literal[src]

impl PartialOrd<Literal> for Literal[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);

type Output = Literal

The resulting type after applying the - operator.

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]

impl Serialize for Literal[src]

impl<'de> Deserialize<'de> for Literal[src]

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]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]