diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-08-17 12:49:48 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-08-17 12:49:48 +0200 |
commit | b9e11915a976daaf790ebc763aff56e19fd49e0f (patch) | |
tree | 7c69dc9427a8a0470ff12f772846b956e747bf78 /src/mode.cpp | |
parent | f9fd78c01623514a060c607534fc52cb73140200 (diff) | |
parent | c7a26bc21629ddd4103dac1ff7f9acf45a2c4d35 (diff) |
Merge insp20
Diffstat (limited to 'src/mode.cpp')
-rw-r--r-- | src/mode.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index b29eda828..3762dc52e 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -791,24 +791,33 @@ std::string ModeParser::GiveModeList(ModeType mt) return type1 + "," + type2 + "," + type3 + "," + type4; } +struct PrefixModeSorter +{ + bool operator()(PrefixMode* lhs, PrefixMode* rhs) + { + return lhs->GetPrefixRank() < rhs->GetPrefixRank(); + } +}; + std::string ModeParser::BuildPrefixes(bool lettersAndModes) { std::string mletters; std::string mprefixes; - insp::flat_map<int, std::pair<char, char> > prefixes; + std::vector<PrefixMode*> prefixes; const PrefixModeList& list = GetPrefixModes(); for (PrefixModeList::const_iterator i = list.begin(); i != list.end(); ++i) { PrefixMode* pm = *i; if (pm->GetPrefix()) - prefixes[pm->GetPrefixRank()] = std::make_pair(pm->GetPrefix(), pm->GetModeChar()); + prefixes.push_back(pm); } - for (insp::flat_map<int, std::pair<char, char> >::reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); ++n) + std::sort(prefixes.begin(), prefixes.end(), PrefixModeSorter()); + for (std::vector<PrefixMode*>::const_reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); ++n) { - mletters = mletters + n->second.first; - mprefixes = mprefixes + n->second.second; + mletters += (*n)->GetPrefix(); + mprefixes += (*n)->GetModeChar(); } return lettersAndModes ? "(" + mprefixes + ")" + mletters : mletters; |