【发布时间】:2012-04-06 14:13:52
【问题描述】:
使用 c++ std 的 unordered_map 我想将整数三元组映射到单个整数,我通常不使用哈希表(不知道它们很酷),但我不知道在这种情况下正确的方法,使用默认散列函数我应该直接映射三元组(类似于 ,int >->int)
std::unordered_map <std::make_pair <make_pair <int,int>,int>,int> hash;
或者可能使用函数将三元组映射到单个值并将该值与默认函数一起使用?
int mapping(int a, int b, int c){
}
std::unordered_map <int,int> hash;
这两种方法都有效,但我想知道哪种方法最有效。谢谢
【问题讨论】:
-
你可以访问std::tuple吗?
-
(“对”只是一种特殊的“元组”:有 2 个元素。)
-
是的,我确实有权访问 std::tuple,我只是不习惯 C++ 库,我会检查一下
标签: c++ hash std unordered-map