我想在项目中使用 unordered_set
。
但是,它的文档要么不完整,要么只是技术引用,没有示例。
任何人都可以提供处理它的在线资源的链接吗?也欢迎书籍,最好是免费的。 Google 搜索没有返回任何有值(value)的信息。
谢谢!
最佳答案
最常见用例的代码:
#include <boost/unordered_set.hpp>
using boost::unordered_set;
using std::string;
using std::cout;
using std::endl;
int main (void)
{
// Initialize set
unordered_set<string> s;
s.insert("red");
s.insert("green");
s.insert("blue");
// Search for membership
if(s.find("red") != s.end())
cout << "found red" << endl;
if(s.find("purple") != s.end())
cout << "found purple" << endl;
if(s.find("blue") != s.end())
cout << "found blue" << endl;
return 0;
}
输出
found red
found blue
更多信息
http://www.cplusplus.com/reference/unordered_set/unordered_set/find/
关于c++ - Boost - unordered_set 教程/示例/任何东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4422893/