public member type
<unordered_map>

std::unordered_multimap::hash_function

hasher hash_function() const;
Get hash function
Returns the hash function object used by the unordered_multimap container.

The hash function is a unary function that takes an object of type key_type as argument and returns a unique value of type size_t based on it. It is adopted by the container on construction (see unordered_multimap's constructor for more info). By default, it is the default hashing function for the corresponding key type: hash<key_type>.

Parameters

none

Return Value

The hash function.

Member type hasher is the type of the hash function used by the container, defined in unordered_multimap as an alias of its third template parameter (Hash).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// unordered_multimap::hash_function
#include <iostream>
#include <string>
#include <unordered_map>

typedef std::unordered_multimap<std::string,std::string> stringmap;

int main ()
{
  stringmap myumm;

  stringmap::hasher fn = myumm.hash_function();

  std::cout << "this: " << fn ("this") << std::endl;
  std::cout << "thin: " << fn ("thin") << std::endl;

  return 0;
}


Possible output:
this: 671344778
thin: 3223852919

Notice how two similar strings yield quite different hash values.

Complexity

Constant.

Iterator validity

No changes.

See also

  • 1793521592 2018-02-23
  • 2864591591 2018-02-23
  • 6167231590 2018-02-23
  • 3669201589 2018-02-23
  • 7946381588 2018-02-23
  • 8957701587 2018-02-23
  • 3891941586 2018-02-23
  • 6039851585 2018-02-23
  • 2573991584 2018-02-23
  • 7728781583 2018-02-23
  • 3731582 2018-02-23
  • 1007451581 2018-02-22
  • 8908121580 2018-02-22
  • 141161579 2018-02-22
  • 9421578 2018-02-22
  • 2826901577 2018-02-22
  • 3647361576 2018-02-22
  • 5717551575 2018-02-22
  • 523811574 2018-02-22
  • 6439871573 2018-02-22