作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想知道是否std::unordered_map< int, float >
仍然必须对给定的整数进行哈希处理才能得到该值,或者直接使用它。我需要每秒多次快速执行此操作,如 std::hash<int>
不能保证是身份函数,我将如何重新定义它? (显然不使用 STL 并编写我自己的容器是可能的,但我怀疑我编写的容器是否会更有效率(可能慢得多,慢得多))。谢谢!
最佳答案
I would like to know whether
std::unordered_map< int, float >
still has to hash the given integer
是的。
I need to perform this operation very fast many times
您是否完成了您的项目并见证了这是它的瓶颈?如果不是,请当心,因为您可能最终成为过早优化的受害者!
how would I go about redefining it?
然后您必须编写自己的代码。示例:C++ unordered_map using a custom class type as the key , 你会在哪里使用 struct Key { int value; };
.
关于c++ - std::unordered_map<int,float> 是否仍然需要散列整数才能得到值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46533991/
我是一名优秀的程序员,十分优秀!