blob: 7c27e9d0d78b187b4331f2a18b965f01770ab3f6 (
plain)
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
33
34
35
36
37
38
39
40
41
42
|
#include "theory/idl/idl_assertion_db.h"
using namespace CVC4;
using namespace theory;
using namespace idl;
IDLAssertionDB::IDLAssertionDB(context::Context* c)
: d_assertions(c)
, d_variableLists(c)
{}
void IDLAssertionDB::add(const IDLAssertion& assertion, TNode var) {
// Is there a list for the variable already?
unsigned previous = -1;
var_to_unsigned_map::iterator find = d_variableLists.find(var);
if (find != d_variableLists.end()) {
previous = (*find).second;
}
// Add to the DB
d_variableLists[var] = d_assertions.size();
d_assertions.push_back(IDLAssertionListElement(assertion, previous));
}
IDLAssertionDB::iterator::iterator(IDLAssertionDB& db, TNode var)
: d_db(db)
, d_current(-1)
{
var_to_unsigned_map::const_iterator find = d_db.d_variableLists.find(var);
if (find != d_db.d_variableLists.end()) {
d_current = (*find).second;
}
}
void IDLAssertionDB::iterator::next() {
if (d_current != (unsigned)(-1)) {
d_current = d_db.d_assertions[d_current].d_previous;
}
}
IDLAssertion IDLAssertionDB::iterator::get() const {
return d_db.d_assertions[d_current].d_assertion;
}
|