summaryrefslogtreecommitdiff
path: root/src/theory/uf/ecdata.cpp
blob: a22faf61ed9fceefb5c17b7d09450c3e14be94a8 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "theory/uf/ecdata.h"

using namespace CVC4;
using namespace context;
using namespace theory;


ECData::ECData(Context * context, const Node & n) :
  ContextObj(context),
  find(this), 
  rep(n), 
  watchListSize(0), 
  first(NULL), 
  last(NULL)
{}


bool ECData::isClassRep(){
  return this == this->find;
}

void ECData::addPredecessor(Node n, Context* context){
  Assert(isClassRep());

  makeCurrent();

  Link * newPred = new (context->getCMM())  Link(context, n, first);
  first = newPred; 
  if(last == NULL){
    last = newPred;
  }

  ++watchListSize;
}

ContextObj* ECData::save(ContextMemoryManager* pCMM) {
  return new(pCMM) ECData(*this);
}

void ECData::restore(ContextObj* pContextObj) {
  *this = *((ECData*)pContextObj);
}

Node ECData::getRep(){
  return rep;
}
  
unsigned ECData::getWatchListSize(){
  return watchListSize;
}

void ECData::setWatchListSize(unsigned newSize){
  Assert(isClassRep());

  makeCurrent();
  watchListSize = newSize;
}

void ECData::setFind(ECData * ec){
  makeCurrent();
  find = ec;
}

ECData * ECData::getFind(){
  return find;
}


Link* ECData::getFirst(){
  return first;
}


Link* ECData::getLast(){
  return last;
}

void ECData::setFirst(Link * nfirst){
  makeCurrent();
  first = nfirst;
}

void ECData::setLast(Link * nlast){
  makeCurrent();
  last = nlast;
}


void ECData::takeOverDescendantWatchList(ECData * nslave, ECData * nmaster){
  Assert(nslave != nmaster);
  Assert(nslave->getFind() == nmaster );

  nmaster->makeCurrent();

  nmaster->watchListSize +=  nslave->watchListSize;

  if(nmaster->first == NULL){
    nmaster->first = nslave->first;
    nmaster->last = nslave->last;
  }else if(nslave->first != NULL){
    Link * currLast = nmaster->last;
    currLast->next = nslave->first;
    nmaster->last = nslave->last;
  }
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback