From: Arnaud Giersch Date: Fri, 4 Feb 2011 22:27:33 +0000 (+0100) Subject: Define globally pneigh_load_less and pneigh_load_grater. X-Git-Tag: v0.1~171 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/af35c0c75c52b0cf5d0518656473503f67a79613 Define globally pneigh_load_less and pneigh_load_grater. Use them to avoid name clash between several `compare' classes. --- diff --git a/loba_fairstrategy.cpp b/loba_fairstrategy.cpp index 98b42cd..552f060 100644 --- a/loba_fairstrategy.cpp +++ b/loba_fairstrategy.cpp @@ -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); diff --git a/loba_makhoul.cpp b/loba_makhoul.cpp index 67a2359..7309e6c 100644 --- a/loba_makhoul.cpp +++ b/loba_makhoul.cpp @@ -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); diff --git a/process.h b/process.h index 86f1f9b..152f5ed 100644 --- 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: