forked from boostorg/unordered
24 lines
893 B
Plaintext
24 lines
893 B
Plaintext
[section:hash_equality Equality Predicates and Hash Functions]
|
|
|
|
[/TODO: A better introduction to hash functions?]
|
|
|
|
While the associative containers use an ordering relation to specify how the
|
|
elements are stored, the unordered associative containers use an equality
|
|
predicate and a hash function. For example [classref boost::unordered_set]
|
|
is declared as:
|
|
|
|
template<typename Value,
|
|
typename Hash = ``[classref boost::hash]``<Value>,
|
|
typename Pred = std::equal_to<Value>,
|
|
typename Alloc = std::allocator<Value> >
|
|
class ``[classref boost::unordered_set unordered_set]``;
|
|
|
|
The hash function comes first as you might want to change the hash function
|
|
but not the equality predicate, while if you were to change the behaviour
|
|
of the equality predicate you would have to change the hash function to match
|
|
it.
|
|
|
|
For example, if you wanted to use
|
|
|
|
[endsect]
|