diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-09-24 17:13:07 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-09-24 17:13:07 +0300 |
commit | 4208c8cd889112aa1adffaa2b6492f61734d1105 (patch) | |
tree | f8f07d170d36c63c2be2904681406429c4cdd57d /src/gui | |
parent | e1e205aaaeb21eb98481c58be70aa6cb9d3b5302 (diff) | |
download | ManaVerse-4208c8cd889112aa1adffaa2b6492f61734d1105.tar.gz ManaVerse-4208c8cd889112aa1adffaa2b6492f61734d1105.tar.bz2 ManaVerse-4208c8cd889112aa1adffaa2b6492f61734d1105.tar.xz ManaVerse-4208c8cd889112aa1adffaa2b6492f61734d1105.zip |
Replace compare function in who is online to functuator.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/whoisonline.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index e1f69c2d7..a14e99afc 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -59,23 +59,27 @@ #undef malloc #endif -bool stringCompare(const std::string &left, const std::string &right); -bool stringCompare(const std::string &left, const std::string &right ) +class NameFunctuator { - for (std::string::const_iterator lit = left.begin(), - rit = right.begin(); - lit != left.end() && rit != right.end(); ++lit, ++rit) - { - if (tolower(*lit) < tolower(*rit)) - return true; - else if (tolower(*lit) > tolower(*rit)) + public: + bool operator()(const std::string &left, + const std::string &right) const + { + for (std::string::const_iterator lit = left.begin(), + rit = right.begin(); + lit != left.end() && rit != right.end(); ++lit, ++rit) + { + if (tolower(*lit) < tolower(*rit)) + return true; + else if (tolower(*lit) > tolower(*rit)) + return false; + } + if (left.size() < right.size()) + return true; return false; - } - if (left.size() < right.size()) - return true; - return false; -} + } +} nameCompare; WhoIsOnline::WhoIsOnline(): Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"), @@ -297,9 +301,9 @@ void WhoIsOnline::loadList() setCaption(_("Who Is Online - ") + toString(numOnline)); //List the online people - sort(friends.begin(), friends.end(), stringCompare); - sort(neutral.begin(), neutral.end(), stringCompare); - sort(disregard.begin(), disregard.end(), stringCompare); + sort(friends.begin(), friends.end(), nameCompare); + sort(neutral.begin(), neutral.end(), nameCompare); + sort(disregard.begin(), disregard.end(), nameCompare); bool addedFromSection(false); for (int i = 0; i < static_cast<int>(friends.size()); i++) { |