WIP: Hard coded appromimated hash function

This commit is contained in:
Andreas Fabri 2019-10-21 10:02:33 +02:00 committed by Laurent Rineau
parent 9303a3318a
commit febb607934
2 changed files with 9 additions and 2 deletions

View File

@ -37,8 +37,14 @@ class Small_unordered_map{
mutable std::array<int, M> occupied;
std::array<int, M> unfreelist;
std::array<std::pair<K,T>, M> data;
const H hash = {};
//const H h = {};
int hash(const K& k)const
{
std::size_t hf = boost::hash<typename K::first_type>()(k.first);
std::size_t hs = boost::hash<typename K::second_type>()(k.second);
return (hf + 1) ^ (419 * (hs + 1));
}
public:
Small_unordered_map()

View File

@ -127,7 +127,8 @@ public:
}
static std::size_t hash_value(const T* p) {
return reinterpret_cast<std::size_t>(p)/sizeof(T);
return reinterpret_cast<std::size_t>(p) >> 5; // sizeof(T);
}
void reset() {}