Changeset View
Changeset View
Standalone View
Standalone View
src/cuckoocache.h
Show First 20 Lines • Show All 243 Lines • ▼ Show 20 Lines | private: | ||||
* precision is required but for a 32-bit random number we only need the | * precision is required but for a 32-bit random number we only need the | ||||
* high 32 bits of a 32*32->64 multiply, which means the operation is | * high 32 bits of a 32*32->64 multiply, which means the operation is | ||||
* reasonably fast even on a typical 32-bit processor. | * reasonably fast even on a typical 32-bit processor. | ||||
* | * | ||||
* @param e the element whose hashes will be returned | * @param e the element whose hashes will be returned | ||||
* @returns std::array<uint32_t, 8> of deterministic hashes derived from e | * @returns std::array<uint32_t, 8> of deterministic hashes derived from e | ||||
*/ | */ | ||||
inline std::array<uint32_t, 8> compute_hashes(const Element &e) const { | inline std::array<uint32_t, 8> compute_hashes(const Element &e) const { | ||||
return { | return {{uint32_t(uint64_t(hash_function.template operator()<0>(e)) * | ||||
{uint32_t( | uint64_t(size) >> | ||||
(hash_function.template operator()<0>(e) * uint64_t(size)) >> | |||||
32), | 32), | ||||
uint32_t( | uint32_t(uint64_t(hash_function.template operator()<1>(e)) * | ||||
(hash_function.template operator()<1>(e) * uint64_t(size)) >> | uint64_t(size) >> | ||||
32), | 32), | ||||
uint32_t( | uint32_t(uint64_t(hash_function.template operator()<2>(e)) * | ||||
(hash_function.template operator()<2>(e) * uint64_t(size)) >> | uint64_t(size) >> | ||||
32), | 32), | ||||
uint32_t( | uint32_t(uint64_t(hash_function.template operator()<3>(e)) * | ||||
(hash_function.template operator()<3>(e) * uint64_t(size)) >> | uint64_t(size) >> | ||||
32), | 32), | ||||
uint32_t( | uint32_t(uint64_t(hash_function.template operator()<4>(e)) * | ||||
(hash_function.template operator()<4>(e) * uint64_t(size)) >> | uint64_t(size) >> | ||||
32), | 32), | ||||
uint32_t( | uint32_t(uint64_t(hash_function.template operator()<5>(e)) * | ||||
(hash_function.template operator()<5>(e) * uint64_t(size)) >> | uint64_t(size) >> | ||||
32), | 32), | ||||
uint32_t( | uint32_t(uint64_t(hash_function.template operator()<6>(e)) * | ||||
(hash_function.template operator()<6>(e) * uint64_t(size)) >> | uint64_t(size) >> | ||||
32), | 32), | ||||
uint32_t( | uint32_t(uint64_t(hash_function.template operator()<7>(e)) * | ||||
(hash_function.template operator()<7>(e) * uint64_t(size)) >> | uint64_t(size) >> | ||||
32)}}; | 32)}}; | ||||
} | } | ||||
/* end | /* end | ||||
* @returns a constexpr index that can never be inserted to */ | * @returns a constexpr index that can never be inserted to */ | ||||
constexpr uint32_t invalid() const { return ~(uint32_t)0; } | constexpr uint32_t invalid() const { return ~(uint32_t)0; } | ||||
/** | /** | ||||
* allow_erase marks the element at index n as discardable. | * allow_erase marks the element at index n as discardable. | ||||
▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines |