From: Arnaud Giersch Date: Thu, 24 Feb 2011 15:13:35 +0000 (+0100) Subject: Use the correct algorithm to find the bound. X-Git-Tag: v0.1~111 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/8996be78fd84b1a3e10a2b7e66b264e28b524ebd?ds=sidebyside Use the correct algorithm to find the bound. Should not change result, just be slightly faster. --- diff --git a/loba_makhoul.cpp b/loba_makhoul.cpp index 2fca60b..dcce7b7 100644 --- a/loba_makhoul.cpp +++ b/loba_makhoul.cpp @@ -10,6 +10,7 @@ void loba_makhoul::load_balance() { using std::tr1::bind; using std::tr1::placeholders::_1; + using std::tr1::placeholders::_2; pneigh_sort_by_load(std::less()); @@ -17,9 +18,10 @@ void loba_makhoul::load_balance() // find limit between least loaded neighbors, and more loaded ones pneigh_type::iterator bound = - std::find_if(pneigh.begin(), pneigh.end(), - bind(std::less_equal(), - get_load(), bind(&neighbor::get_load, _1))); + std::lower_bound(pneigh.begin(), pneigh.end(), + get_load(), + bind(std::less(), + bind(&neighbor::get_load, _1), _2)); // compute load differences std::vector delta(bound - pneigh.begin());