xtd 0.2.0
xtd::collections::generic::helpers::hasher< key_t > Struct Template Reference

Definition

template<class key_t>
struct xtd::collections::generic::helpers::hasher< key_t >

Implements a function object for hashing data.

template<class key_t>
struct hasher;
Implements a function object for hashing data.
Definition hasher.hpp:39
Header
#include <xtd/collections/generic/helpers/hasher>
Namespace
xtd::collections::generic::helpers
Library
xtd.core
Remarks
The unordered associative containers xtd::collections::generic::has_set, xtd::collections::generic::hash_multi_set, xtd::collections::generic::dictionary, xtd::collections::generic::multi_dictionary use specializations of the template xtd::collections::generic::helpers::hasher as the default hash function.
Examples
The following example show how to use xtd::collections::generic::helpers::hasher with std::unordered_map.
auto key_values = std::unordered_map<xtd::date_time, xtd::string, xtd::collections::generic::helpers::hasher<xtd::date_time>, xtd::collections::generic::helpers::equator<xtd::date_time>, xtd::collections::generic::helpers::allocator<xtd::collections::generic::key_value_pair<const xtd::date_time, xtd::string>>> {};
key_values.insert({{1971, 1, 5}, "Birth date"});
std::allocator< type_t > allocator
Represent an allocator alias.
Definition allocator.hpp:38
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:38

Public Aliases

using argument_type = key_t
 Represents the argument type.
 
using result_type = xtd::size
 Represents the result type.
 

Public Operators

result_type operator() (const argument_type &key) const
 Serves as a hash function for a specified key with a particular type (type_t).
 

Member Typedef Documentation

◆ argument_type

template<class key_t >
using xtd::collections::generic::helpers::hasher< key_t >::argument_type = key_t

Represents the argument type.

◆ result_type

template<class key_t >
using xtd::collections::generic::helpers::hasher< key_t >::result_type = xtd::size

Represents the result type.

Member Function Documentation

◆ operator()()

template<class key_t >
result_type xtd::collections::generic::helpers::hasher< key_t >::operator() ( const argument_type key) const
inline

Serves as a hash function for a specified key with a particular type (type_t).

Parameters
keyThe key to hash.
Returns
A hash code for the spesified key.
Remarks
If key_t inherits from xtd::object, the xtd::object::get_hash_code method will be used; otherwise, the std::hash object function will be used.

The documentation for this struct was generated from the following file: