-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSATClause.cpp
More file actions
32 lines (28 loc) · 765 Bytes
/
SATClause.cpp
File metadata and controls
32 lines (28 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// Created by Dominik Plíšek on 22/01/16.
//
#include <iostream>
#include "SATClause.h"
istream &operator>>(istream &in, SATClause &clause) {
for (int i = 0; i < clause.clauseSize; ++i) {
int var;
in >> var;
clause.variables[i] = abs(var) - 1; // we index from 0
clause.positive[i] = var > 0;
}
int term;
in >> term;
if (term != 0) {
cerr << "Error while reading clause, missing terminator 0." << endl;
exit(EXIT_FAILURE);
}
return in;
}
SATClause::SATClause(int clauseSize, int index) : clauseSize(clauseSize), index(index) {
variables = new int[clauseSize];
positive = new bool[clauseSize];
}
SATClause::~SATClause() {
delete [] variables;
delete [] positive;
}