Project

General

Profile

Statistics
| Branch: | Revision:

cool / src / lib / GMLMIP-0.1 / rules / node.cpp @ 7c4d2eb4

History | View | Annotate | Download (1.01 KB)

1 e034e268 Thorsten Wißmann
#include "node.h"
2
3
void Node::allow(int a){
4
        valuations[a] = 1;
5
}
6
7
void Node::disallow(int d){
8
        valuations[d] = 0;
9
}
10
11
Node::Node(int no_of_atoms) : size (static_cast<int>(pow(2, no_of_atoms))), valuations(size, 0){
12
        //valuations.resize(size, 0);
13
14
        // needs to be replaced with actually initing the stuff
15
        //for(int i=0; i < size; i++)
16
                //valuations[i]=0;
17
}
18
19
bool Node::operator==(const Node& other) const{
20
        if(size == other.size){
21
                for(int i=0; i < size; i++)
22
                        if(valuations[i] != other.valuations[i])
23
                                return false;
24
                return true;
25
        }
26
        return false;
27
}
28
29
30
bool Node::operator<(const Node& other) const{
31
        if(size == other.size){
32
                for(int i=0; i < size; i++)
33
                        if(valuations[i]==1 && other.valuations[i]==0)
34
                                return false;
35
        return true;
36
        }
37
        cout << "you checked for supersets with nodes of different sizes - you probably didn't mean to do this..." << endl;
38
        return false;
39
}
40
41
ostream& operator<<(ostream& out, const Node& n){
42
        out << n.size << endl;
43
        for(int i=0; i < n.size; i++)
44
                out << n.valuations[i] << " ";
45
        out << endl;
46
}