* @param action The ModelAction to find a node for
* @return The CycleNode paired with this action
*/
-CycleNode * CycleGraph::getNode(const ModelAction *action)
+CycleNode * CycleGraph::getNode(ModelAction *action)
{
CycleNode *node = getNode_noCreate(action);
if (node == NULL) {
* If the fromnode has a rmwnode, we should
* follow its RMW chain to add an edge at the end.
*/
- while (fromnode->getRMW()) {
- CycleNode *nextnode = fromnode->getRMW();
+ while (CycleNode * nextnode = fromnode->getRMW()) {
if (nextnode == tonode)
break;
fromnode = nextnode;
* @param rmw The edge points to this ModelAction; this action must read from
* the ModelAction from
*/
-void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw)
+void CycleGraph::addRMWEdge(ModelAction *from, ModelAction *rmw)
{
ASSERT(from);
ASSERT(rmw);
addNodeEdge(fromnode, rmwnode, true);
}
-void CycleGraph::addEdges(SnapList<ModelAction *> * edgeset, const ModelAction *to) {
+void CycleGraph::addEdges(SnapList<ModelAction *> * edgeset, ModelAction *to) {
for(sllnode<ModelAction*> * it = edgeset->begin();it!=NULL;) {
ModelAction *act = it->getVal();
CycleNode *node = getNode(act);
* @return True, if new edge(s) are added; otherwise false
*/
-void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to)
+void CycleGraph::addEdge(ModelAction *from, ModelAction *to)
{
ASSERT(from);
ASSERT(to);
addNodeEdge(fromnode, tonode, false);
}
-void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to, bool forceedge)
+void CycleGraph::addEdge(ModelAction *from, ModelAction *to, bool forceedge)
{
ASSERT(from);
ASSERT(to);
CycleNode *dst = cn->edges[i];
dst->removeInEdge(cn);
}
+ for(unsigned int i=0;i<cn->inedges.size();i++) {
+ CycleNode *src = cn->inedges[i];
+ src->removeEdge(cn);
+ }
delete cn;
}
* @brief Constructor for a CycleNode
* @param act The ModelAction for this node
*/
-CycleNode::CycleNode(const ModelAction *act) :
+CycleNode::CycleNode(ModelAction *act) :
action(act),
hasRMW(NULL),
cv(new ClockVector(NULL, act))
}
void CycleNode::removeInEdge(CycleNode *src) {
+ for(unsigned int i=0;i < inedges.size();i++) {
+ if (inedges[i] == src) {
+ inedges[i] = inedges[inedges.size()-1];
+ inedges.pop_back();
+ break;
+ }
+ }
+}
+
+void CycleNode::removeEdge(CycleNode *dst) {
for(unsigned int i=0;i < edges.size();i++) {
- if (edges[i] == src) {
+ if (edges[i] == dst) {
edges[i] = edges[edges.size()-1];
edges.pop_back();
break;
return edges.size();
}
+/**
+ * @param i The index of the edge to return
+ * @returns The CycleNode edge indexed by i
+ */
+CycleNode * CycleNode::getInEdge(unsigned int i) const
+{
+ return inedges[i];
+}
+
+/** @returns The number of edges leaving this CycleNode */
+unsigned int CycleNode::getNumInEdges() const
+{
+ return inedges.size();
+}
+
/**
* Adds an edge from this CycleNode to another CycleNode.
* @param node The node to which we add a directed edge