您好我不知道我是否可以设置另一个链接的结构自己实际上在unordered_map中的键之间设置我自己的顺序?或者有一个标准库?我需要unordered_map的快速查找功能...在unordered_map上构造的混合链表?
例如:
#include<string>
#include<tr1/unordered_map>
struct linker
{
string *pt;
string *child1;
string *child2;
};
unordered_map<string,int> map({{"aaa",1},{"bbb",2},{"ccc",3},{"ddd",4}});
linker node1 = new linker;
node1.pt = &map.find("aaa")->first;
node1.child1 = &map.find("ccc")->first;
node1.child2 = &map.find("ddd")->first;
存储迭代器而不是指针可能会更好。 – imreal
@Nick,但如果大小改变并重新设置,迭代器将会改变。不是吗? – weeo
有很多事情使迭代器和指针无效,你必须小心不管哪种方式。 – imreal