std::string FindWord(const trie_type& trie, const std::string& keys, size_t alternative) { typedef std::vector<Word> Words; trie_type::result_type candidates = trie.find(keys); Words::const_iterator match; Words words(candidates.first, candidates.second); std::sort(words.begin(), words.end(), boost::mem_fn(&Word::MoreFrequent)); for (Words::const_iterator word = words.begin(); word != words.end(); ++word) { match = word; if (alternative == 0) { break; } else { --alternative; } } if (match == words.end()) { return "No alternative"; } else { return match->str(); } }
iterator find(const Container& container) { return t.find(container); }
iterator find(Iter first, Iter last) { return t.find(first, last); }