cnf::Clause Class Reference

This class is used to manipulate CNF clauses. More...

#include <clause.h>

List of all members.

Public Member Functions

 Clause ()
 Builds an empty Clause instance.
void addLit (int)
 Adds the code of the literal given as an argument to the Clause.
std::string toString ()
 Puts all the literals in a one line std::string.
void clear ()
 Clears the content of the clause by clearing the literals attribute.

Private Attributes

std::vector< int > literals
 The codes of the variables of the clause.

Detailed Description

This class is used to manipulate CNF clauses.

A CNF clause consist of the disjunction of an arbitrary number of literals. This class makes it easier to use these in coordination with the minisat2 program.

Definition at line 24 of file clause.h.


Constructor & Destructor Documentation

Builds an empty Clause instance.

Definition at line 18 of file clause.cpp.

{
        literals.clear();
}

Member Function Documentation

void Clause::addLit ( int  code)

Adds the code of the literal given as an argument to the Clause.

Definition at line 23 of file clause.cpp.

{
        literals.push_back(code);
}
void Clause::clear ( )

Clears the content of the clause by clearing the literals attribute.

Definition at line 40 of file clause.cpp.

{
        literals.clear();
}
std::string Clause::toString ( )

Puts all the literals in a one line std::string.

The aim of this method is to write a line of a DIMACS formatted file corresponding to this disjunction.

Definition at line 28 of file clause.cpp.

{
        std::stringstream s(std::stringstream::out);
        for (unsigned int i=0; i<literals.size(); i++)
        {
                s << literals[i] << " ";
        }
        std::string res = s.str() + "0";
        s.flush();
        return res;
}

Member Data Documentation

std::vector<int> cnf::Clause::literals [private]

The codes of the variables of the clause.

If the literal is negated, it contains the opposite of its code instead of its code according to the DIMACS encoding.

Definition at line 33 of file clause.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Defines