uint64_t thisValue = getElement(thisIndex);
while (thisIndex < thisSize && sIndex < sSize) {
if (sValue < thisValue) {
- sValue = s->getElement(++sIndex);
+ sIndex++;
+ if (sIndex < sSize)
+ sValue = s->getElement(sIndex);
sum++;
} else if (thisValue < sValue) {
- thisValue = getElement(++thisIndex);
+ thisIndex++;
+ if (thisIndex < thisSize)
+ thisValue = getElement(thisIndex);
sum++;
} else {
- thisValue = getElement(++thisIndex);
- sValue = s->getElement(++sIndex);
+ thisIndex++;
+ sIndex++;
+ if (sIndex < sSize)
+ sValue = s->getElement(sIndex);
+ if (thisIndex < thisSize)
+ thisValue = getElement(thisIndex);
sum++;
}
}
solver(_solver) {
}
+EncodingGraph::~EncodingGraph() {
+ subgraphs.resetAndDelete();
+ encodingMap.resetAndDeleteVals();
+ edgeMap.resetAndDeleteVals();
+}
+
int sortEncodingEdge(const void *p1, const void *p2) {
const EncodingEdge *e1 = *(const EncodingEdge **) p1;
const EncodingEdge *e2 = *(const EncodingEdge **) p2;
class EncodingGraph {
public:
EncodingGraph(CSolver *solver);
+ ~EncodingGraph();
void buildGraph();
void encode();
maxEncodingVal(0) {
}
+EncodingSubGraph::~EncodingSubGraph() {
+ map.resetAndDeleteKeys();
+ values.resetAndDelete();
+}
+
uint hashNodeValuePair(NodeValuePair *nvp) {
return (uint) (nvp->value ^ ((uintptr_t)nvp->node));
}
class EncodingSubGraph {
public:
EncodingSubGraph();
+ ~EncodingSubGraph();
void addNode(EncodingNode *n);
SetIteratorEncodingNode *nodeIterator();
void encode();
}
}
- table->resetanddelete();
+ table->resetAndDeleteVals();
delete table;
resetNodeInfoStatusSCC(graph);
}
}
}
- table->resetanddelete();
+ table->resetAndDeleteVals();
delete table;
}
table->reset();
}
+ void resetAndDelete() {
+ Linknode<_Key> *tmp = list;
+ while (tmp != NULL) {
+ Linknode<_Key> *tmpnext = tmp->next;
+ ourfree(tmp);
+ tmp = tmpnext;
+ }
+ list = tail = NULL;
+ table->resetAndDeleteKeys();
+ }
+
/** @brief Adds a new key to the hashset. Returns false if the key
* is already present. */
}
}
- void resetanddelete() {
+ void resetAndDeleteKeys() {
+ for (unsigned int i = 0; i < capacity; i++) {
+ struct Hashlistnode<_Key, _Val> *bin = &table[i];
+ if (bin->key != NULL) {
+ delete bin->key;
+ bin->key = NULL;
+ if (bin->val != NULL) {
+ bin->val = NULL;
+ }
+ }
+ }
+ if (zero) {
+ ourfree(zero);
+ zero = NULL;
+ }
+ size = 0;
+ }
+
+ void resetAndDeleteVals() {
for (unsigned int i = 0; i < capacity; i++) {
struct Hashlistnode<_Key, _Val> *bin = &table[i];
if (bin->key != NULL) {
size = 0;
}
- void resetandfree() {
+ void resetAndFreeVals() {
for (unsigned int i = 0; i < capacity; i++) {
struct Hashlistnode<_Key, _Val> *bin = &table[i];
if (bin->key != NULL) {
OrderPairResolver::~OrderPairResolver() {
if (orderPairTable != NULL) {
- orderPairTable->resetanddelete();
+ orderPairTable->resetAndDeleteVals();
delete orderPairTable;
}
}