Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
Clasp::Literal Class Reference

A literal is a variable or its negation. More...

#include <literal.h>

List of all members.

Public Member Functions

uint32 & asUint ()
uint32 asUint () const
void clearWatch ()
 Clears the watched-flag of this literal.
uint32 index () const
 Returns the unique index of this literal.
 Literal ()
 The default constructor creates the positive literal of the special sentinel var.
 Literal (Var var, bool sign)
 Creates a literal of the variable var with sign s.
bool operator== (const Literal &rhs) const
 Equality-Comparison for literals.
Literal operator~ () const
 Returns the complimentary literal of this literal.
bool sign () const
 Returns the sign of the literal.
void swap (Literal &other)
Var var () const
 Returns the variable of the literal.
void watch ()
 Sets the watched-flag of this literal.
bool watched () const
 Returns true if the watched-flag of this literal is set.

Static Public Member Functions

static Literal fromIndex (uint32 idx)
 Creates a literal from an index.
static Literal fromRep (uint32 rep)
 Creates a literal from an unsigned integer.

Private Member Functions

 Literal (uint32 rep)

Private Attributes

uint32 rep_

Detailed Description

A literal is a variable or its negation.

A literal is determined by two things: a sign and a variable index.

Implementation:
A literal's state is stored in a single 32-bit integer as follows:
  • 30-bits : var-index
  • 1-bit : sign, 1 if negative, 0 if positive
  • 1-bit : watch-flag

Definition at line 80 of file literal.h.


Constructor & Destructor Documentation

The default constructor creates the positive literal of the special sentinel var.

Definition at line 83 of file literal.h.

Clasp::Literal::Literal ( Var  var,
bool  sign 
) [inline]

Creates a literal of the variable var with sign s.

Parameters:
varThe literal's variable.
strue if new literal should be negative.
Precondition:
var < varMax

Definition at line 91 of file literal.h.

Clasp::Literal::Literal ( uint32  rep) [inline, private]

Definition at line 156 of file literal.h.


Member Function Documentation

uint32& Clasp::Literal::asUint ( ) [inline]

Definition at line 113 of file literal.h.

uint32 Clasp::Literal::asUint ( ) const [inline]

Definition at line 114 of file literal.h.

void Clasp::Literal::clearWatch ( ) [inline]

Clears the watched-flag of this literal.

Definition at line 131 of file literal.h.

static Literal Clasp::Literal::fromIndex ( uint32  idx) [inline, static]

Creates a literal from an index.

Precondition:
idx < 2^31

Definition at line 105 of file literal.h.

static Literal Clasp::Literal::fromRep ( uint32  rep) [inline, static]

Creates a literal from an unsigned integer.

Definition at line 111 of file literal.h.

uint32 Clasp::Literal::index ( ) const [inline]

Returns the unique index of this literal.

Note:
The watch-flag is ignored and thus the index of a literal can be stored in 31-bits.

Definition at line 99 of file literal.h.

bool Clasp::Literal::operator== ( const Literal rhs) const [inline]

Equality-Comparison for literals.

Two Literals p and q are equal, iff

  • they both refer to the same variable
  • they have the same sign

Definition at line 152 of file literal.h.

Literal Clasp::Literal::operator~ ( ) const [inline]

Returns the complimentary literal of this literal.

The complementary Literal of a Literal is a Literal referring to the same variable but with inverted sign.

Definition at line 141 of file literal.h.

bool Clasp::Literal::sign ( ) const [inline]

Returns the sign of the literal.

Returns:
true if the literal is negative. Otherwise false.

Definition at line 123 of file literal.h.

void Clasp::Literal::swap ( Literal other) [inline]

Definition at line 125 of file literal.h.

Var Clasp::Literal::var ( ) const [inline]

Returns the variable of the literal.

Definition at line 117 of file literal.h.

void Clasp::Literal::watch ( ) [inline]

Sets the watched-flag of this literal.

Definition at line 128 of file literal.h.

bool Clasp::Literal::watched ( ) const [inline]

Returns true if the watched-flag of this literal is set.

Definition at line 134 of file literal.h.


Member Data Documentation

uint32 Clasp::Literal::rep_ [private]

Definition at line 157 of file literal.h.


The documentation for this class was generated from the following file:


clasp
Author(s): Benjamin Kaufmann
autogenerated on Thu Aug 27 2015 12:41:41