}
void CycleGraph::addEdges(SnapList<ModelAction *> * edgeset, const ModelAction *to) {
- for(SnapList<ModelAction*>::iterator it = edgeset->begin();it!=edgeset->end();) {
- ModelAction *act = *it;
+ for(sllnode<ModelAction*> * it = edgeset->begin();it!=NULL;) {
+ ModelAction *act = it->getVal();
CycleNode *node = getNode(act);
- SnapList<ModelAction*>::iterator it2 = it;
- it2++;
- for(;it2!=edgeset->end(); ) {
- ModelAction *act2 = *it2;
+ sllnode<ModelAction*> * it2 = it;
+ it2=it2->getNext();
+ for(;it2!=NULL; ) {
+ ModelAction *act2 = it2->getVal();
CycleNode *node2 = getNode(act2);
if (checkReachable(node, node2)) {
it = edgeset->erase(it);
it2 = edgeset->erase(it2);
goto endinnerloop;
}
- it2++;
+ it2=it2->getNext();
endinnerloop:
;
}
- it++;
+ it=it->getNext();
endouterloop:
;
}
- for(SnapList<ModelAction*>::iterator it = edgeset->begin();it!=edgeset->end();it++) {
- ModelAction *from = *it;
+ for(sllnode<ModelAction*> *it = edgeset->begin();it!=NULL;it=it->getNext()) {
+ ModelAction *from = it->getVal();
addEdge(from, to, from->get_tid() == to->get_tid());
}
}
_Tp getVal() {return val;}
mllnode<_Tp> * getNext() {return next;}
mllnode<_Tp> * getPrev() {return prev;}
+
MEMALLOC;
private:
mllnode<_Tp> * next;
mllnode<_Tp> * prev;
_Tp val;
+ template<typename T>
friend class ModelList;
};
}
}
- void erase(mllnode<_Tp> * node) {
+ mllnode<_Tp> * erase(mllnode<_Tp> * node) {
if (head == node) {
head = node->next;
} else {
} else {
tail->next->prev = node->prev;
}
-
+ mllnode<_Tp> *next = node->next;
delete node;
+ return next;
}
- mllnode<_Tp> begin() {
+ mllnode<_Tp> * begin() {
return head;
}
- mllnode<_Tp> end() {
+ mllnode<_Tp> * end() {
return tail;
}
sllnode<_Tp> * next;
sllnode<_Tp> * prev;
_Tp val;
+ template<typename T>
friend class SnapList;
};
}
}
- void erase(sllnode<_Tp> * node) {
+ sllnode<_Tp> * erase(sllnode<_Tp> * node) {
if (head == node) {
head = node->next;
} else {
} else {
tail->next->prev = node->prev;
}
-
+
+ sllnode<_Tp> *next = node->next;
delete node;
+ return next;
}
- sllnode<_Tp> begin() {
+ sllnode<_Tp> * begin() {
return head;
}
- sllnode<_Tp> end() {
+ sllnode<_Tp> * end() {
return tail;
}