Cli*_*ton 2 c++ algorithm optimization data-structures c++11
C++(或C++ 11)中的标准结构或库是否类似于a set,但可能有多个key.
即一组的std ::对可以由任一快速进行查找a或b.
所以你可以这样做:
std::string a = "hello";
std::string b = "world";
x.insert(a, b);
x.get<1>("hello") => std::pair("hello", "world"); // (fast lookup)
x.get<2>("world") => std::pair("hello", "world"); // (fast lookup)
Run Code Online (Sandbox Code Playgroud)
基本上就像一个带有两个索引的数据库表.
如果已经存在某些东西,我宁愿不重新发明轮子.
组合现有容器以使用此功能创建内容的简单方法也会很好.