Cachemere
Modular Caching Library for C++
hash_mixer.hpp
1 namespace cachemere::policy::detail {
2 
3 template<typename Key, typename KeyHash>
4 HashMixer<Key, KeyHash>::HashMixer(const Key& key, size_t value_range)
5  : KeyHash{},
6  m_rng{static_cast<std::minstd_rand::result_type>(KeyHash::operator()(key))},
7  m_value_range{value_range}
8 {
9 }
10 
11 template<typename Key, typename KeyHash> size_t HashMixer<Key, KeyHash>::operator()()
12 {
13  return m_rng() % m_value_range;
14 }
15 
16 } // namespace cachemere::policy::detail
cachemere::policy::detail::HashMixer::HashMixer
HashMixer(const Key &key, size_t value_range)
Constructor.
Definition: hash_mixer.hpp:4
cachemere::policy::detail::HashMixer::operator()
size_t operator()()
Generate the next value in the random sequence.
Definition: hash_mixer.hpp:11