File tree 3 files changed +12
-9
lines changed
3 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 1
1
#include " ROBDD.hpp"
2
2
#include < fstream>
3
+ bool BDD_node::operator ==(const BDD_node &rhs) const
4
+ {
5
+ return this ->var == rhs.var && this ->low == rhs.low && this ->high == rhs.high ;
6
+ }
3
7
ROBDD::ROBDD ()
4
8
{
5
9
this ->zero = new BDD_node ({0 , nullptr , nullptr });
@@ -8,11 +12,11 @@ ROBDD::ROBDD()
8
12
this ->node_table [*(this ->one )] = this ->one ;
9
13
}
10
14
11
- BDD_node* ROBDD::get_one () const
15
+ BDD_node * ROBDD::get_one () const
12
16
{
13
17
return this ->one ;
14
18
}
15
- BDD_node* ROBDD::get_zero () const
19
+ BDD_node * ROBDD::get_zero () const
16
20
{
17
21
return this ->zero ;
18
22
}
@@ -173,7 +177,6 @@ void ROBDD::output(std::ofstream &out)
173
177
this ->printed .clear ();
174
178
}
175
179
176
-
177
180
void ROBDD::_output (BDD_node *node, std::ofstream &out)
178
181
{
179
182
// print node itself
@@ -187,7 +190,7 @@ void ROBDD::_output(BDD_node *node, std::ofstream &out)
187
190
out << this ->ID_to_var [node->var ];
188
191
else
189
192
out << node->var ;
190
- out << " \" ]" << std::endl; // use label as node name
193
+ out << " \" ]" << std::endl; // use label as node name
191
194
}
192
195
// no subnodes
193
196
if (node->var <= 1 )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ struct BDD_node
17
17
// var = 0 and var = 1 reserved
18
18
unsigned int var;
19
19
BDD_node *low, *high;
20
- bool operator ==(const BDD_node &rhs) const { return this -> var == rhs. var && this -> low == rhs. low && this -> high == rhs. high ; }
20
+ bool operator ==(const BDD_node &rhs) const ;
21
21
};
22
22
struct ROBDD
23
23
{
@@ -26,8 +26,8 @@ struct ROBDD
26
26
{
27
27
std::size_t operator ()(const BDD_node &T) const
28
28
{
29
- return std::hash<void *>()(static_cast <void *>(T.low ))
30
- ^ std::hash<void *>()(static_cast <void *>(T.high ))
29
+ return ( std::hash<void *>()(static_cast <void *>(T.low )) // hash result affected by order
30
+ - std::hash<void *>()(static_cast <void *>(T.high ) ))
31
31
^ std::hash<int >()(T.var );
32
32
}
33
33
};
@@ -36,7 +36,7 @@ struct ROBDD
36
36
std::size_t operator ()(const std::pair<BDD_node *, BDD_node *> &T) const
37
37
{
38
38
return std::hash<void *>()(static_cast <void *>(T.first ))
39
- ^ std::hash<void *>()(static_cast <void *>(T.second ));
39
+ - std::hash<void *>()(static_cast <void *>(T.second ));
40
40
}
41
41
};
42
42
BDD_node *root;
Original file line number Diff line number Diff line change 47
47
| term {$$ = $1;}
48
48
49
49
term
50
- : NOT atom {$$ = $2; auto tmp = $$->high; $$ ->high = $$ ->low; $$->low = tmp ;}
50
+ : NOT atom {$$ = T->make_node($2->var, $2 ->high, $2 ->low) ;}
51
51
| atom {$$ = $1;}
52
52
53
53
atom
You can’t perform that action at this time.
0 commit comments