Why providing an hash function without specifing any implementation of reference and also without specifying the algorithm of reference ( md5, sha256, etc etc ) ?

Also there are similar features for data structures such as the C++ standard-compliant std::unordered_map/set/multimap/multiset::hash_function.

So what i don't get is:

  • 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 ?
有帮助吗?

解决方案

Why providing such undocumented methods

They are not undocumented.

The implementation details are fundamental for a right use of the hash functions, from a programmer standpoint what is the purpose of these functions

The implementation is unspecified, they are just supposed to be used together with unordered containers. They should be as good a hash function as possible, to effectively distribute elements into buckets. Anything else is unspecified.

Note that user is expected to provide these if using unordered containers with user defined types.

This function can be linked to a specific algorithm ?

Why not?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top