Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
code simplification: write the recursivity properly
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 16 Nov 2016 00:40:07 +0000 (01:40 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 16 Nov 2016 00:40:07 +0000 (01:40 +0100)
src/kernel/routing/AsImpl.cpp
src/kernel/routing/AsRoutedGraph.cpp
src/surf/surf_routing.cpp

index 9fe0cef..a0841b9 100644 (file)
@@ -43,6 +43,13 @@ namespace simgrid {
 
   void AsImpl::getOneLinkRoutes(std::vector<Onelink*>* accumulator)
   {
 
   void AsImpl::getOneLinkRoutes(std::vector<Onelink*>* accumulator)
   {
+    // recursing only. I have no route myself :)
+    char* key;
+    xbt_dict_cursor_t cursor = nullptr;
+    AsImpl* rc_child;
+    xbt_dict_foreach (children(), cursor, key, rc_child) {
+      rc_child->getOneLinkRoutes(accumulator);
+    }
   }
 
   /** @brief Get the common ancestor and its first children in each line leading to src and dst
   }
 
   /** @brief Get the common ancestor and its first children in each line leading to src and dst
index 592ad3c..20b0910 100644 (file)
@@ -107,7 +107,8 @@ void AsRoutedGraph::getOneLinkRoutes(std::vector<Onelink*>* accumulator)
       }
     }
   }
       }
     }
   }
-  }
+  AsImpl::getOneLinkRoutes(accumulator); // Recursivly call this function on all my childs too
+}
 
 void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
 
 void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
index b1b6a12..d4cd3d5 100644 (file)
@@ -100,24 +100,10 @@ void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Li
   AsImpl::getRouteRecursive(src, dst, route, latency);
 }
 
   AsImpl::getRouteRecursive(src, dst, route, latency);
 }
 
-static void _recursiveGetOneLinkRoutes(AsImpl* as, std::vector<Onelink*>* accumulator)
-{
-  //adding my one link routes
-  as->getOneLinkRoutes(accumulator);
-
-  //recursing
-  char *key;
-  xbt_dict_cursor_t cursor = nullptr;
-  AsImpl *rc_child;
-  xbt_dict_foreach(as->children(), cursor, key, rc_child) {
-    _recursiveGetOneLinkRoutes(rc_child, accumulator);
-  }
-}
-
 std::vector<Onelink*>* RoutingPlatf::getOneLinkRoutes()
 {
   std::vector<Onelink*>* res = new std::vector<Onelink*>();
 std::vector<Onelink*>* RoutingPlatf::getOneLinkRoutes()
 {
   std::vector<Onelink*>* res = new std::vector<Onelink*>();
-  _recursiveGetOneLinkRoutes(root_, res);
+  root_->getOneLinkRoutes(res);
   return res;
 }
 
   return res;
 }