为什么提供哈希函数而不指定引用的任何实现,也不指定引用的算法(md5、sha256 等)?
数据结构也有类似的特性,例如符合 C++ 标准的 std::unordered_map/set/multimap/multiset::hash_function
。
所以我没有得到的是:
- 为什么提供这种未记录的方法
- 实现细节是正确使用散列函数的基础,从程序员的角度来看,这些函数的目的是什么
- 这个函数可以链接到一个特定的算法?
最佳答案
Why providing such undocumented methods
它们并非未记录。
The implementation details are fundamental for a right use of the hash functions, from a programmer standpoint what is the purpose of these functions
实现未指定,它们只是应该与无序容器一起使用。它们应该是尽可能好的哈希函数,以有效地将元素分配到桶中。其他未指定。
请注意,如果使用具有用户定义类型的无序容器,用户应该提供这些。
This function can be linked to a specific algorithm ?
为什么不呢?
关于c++ - std::hash 和/或 boost::hash 的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14017674/