小智 8
struct Dictionary {
Dictionary() {
// load _words, here's one possible implementation:
std::ifstream input ("/usr/share/dict/words");
for (std::string line; getline(input, line);) {
_words.insert(line);
}
}
bool contains(std::string const& word) const { return _words.count(word); }
std::set<std::string> _words;
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8680 次 |
| 最近记录: |