]> AND Private Git Repository - loba.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Define globally pneigh_load_less and pneigh_load_grater.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 4 Feb 2011 22:27:33 +0000 (23:27 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 4 Feb 2011 22:27:33 +0000 (23:27 +0100)
Use them to avoid name clash between several `compare' classes.

loba_fairstrategy.cpp
loba_makhoul.cpp
process.h

index 98b42cd831bbf23f70533d32858cdc8e014af8c4..552f060bd0315dedc795b3049ee1abe4c096c05c 100644 (file)
@@ -5,18 +5,11 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
 
 #include "loba_fairstrategy.h"
 
-class compare {
-public:
-    bool operator()(const neighbor*a, const neighbor*b) {
-        return a->get_load() > b->get_load();
-    }
-};
-
 void loba_fairstrategy::load_balance()
 {
     const double delta = 0.001;
 
-    std::sort(pneigh.begin(), pneigh.end(), compare());
+    std::sort(pneigh.begin(), pneigh.end(), pneigh_load_greater());
 
     print_loads_p(false, xbt_log_priority_debug);
 
index 67a2359c569cf18f669ac17193125e0dfe2cdb36..7309e6c52beccc33572a1b0c744ea798cf84ac7b 100644 (file)
@@ -5,16 +5,9 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
 
 #include "loba_makhoul.h"
 
-class compare {
-public:
-    bool operator()(const neighbor*a, const neighbor*b) {
-        return a->get_load() < b->get_load();
-    }
-};
-
 void loba_makhoul::load_balance()
 {
-    std::sort(pneigh.begin(), pneigh.end(), compare());
+    std::sort(pneigh.begin(), pneigh.end(), pneigh_load_less());
 
     print_loads_p(false, xbt_log_priority_debug);
 
index 86f1f9b40b76eff8478615b81fb2c358a5187542..152f5ed1c5e45a02f413e08394e93ee602bcde2c 100644 (file)
--- a/process.h
+++ b/process.h
@@ -132,6 +132,20 @@ void process::set_load(double load)
         real_load = load;
 }
 
+struct pneigh_load_less {
+    bool operator()(const neighbor* a, const neighbor* b)
+    {
+        return a->get_load() < b->get_load();
+    }
+};
+
+struct pneigh_load_greater {
+    bool operator()(const neighbor* a, const neighbor* b)
+    {
+        return a->get_load() > b->get_load();
+    }
+};
+
 #endif // !PROCESS_H
 
 // Local variables: