Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Wordlist::fillMap()
- {
- std::for_each(words.begin(), words.end(),
- [&](std::string s)
- {
- linkedWords[s]++;
- });
- }
- void Wordlist::minusF()
- {
- fillMap();
- typedef std::pair<std::string,int> pair;
- std::copy(linkedWords.begin(), linkedWords.end(),
- std::back_inserter<std::vector<pair>>(vectorPair));
- size_t size{};
- std::sort(vectorPair.begin(), vectorPair.end(),
- [&size](pair const & a, pair const & b)
- {
- if(size < a.first.size())
- size = a.first.size();
- return a.second > b.second;
- });
- std::for_each(vectorPair.begin(), vectorPair.end(),
- [size](pair const & a)
- {
- std::cout << std::setw(size) << a.first << '\t' << a.second << std::endl;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement