From af35c0c75c52b0cf5d0518656473503f67a79613 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 4 Feb 2011 23:27:33 +0100 Subject: [PATCH] Define globally pneigh_load_less and pneigh_load_grater. Use them to avoid name clash between several `compare' classes. --- loba_fairstrategy.cpp | 9 +-------- loba_makhoul.cpp | 9 +-------- process.h | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 16 deletions(-) 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: -- 2.39.5