How to incorporate the following bit mixing code in order to minimize the hash collisions inside the unordered_map?
UInt64 MurmurHash3Mixer( UInt64 key )
{
key ^= (key >> 33);
key *= 0xff51afd7ed558ccd;
key ^= (key >> 33);
key *= 0xc4ceb9fe1a85ec53;
key ^= (key >> 33);
return key;
}
Posted code was referred from the site.
Following is the full code (testing code) just to get 'MurmurHash3Mixer' included into the 'std::unordered_map' hashing scheme.
#include <iostream>
#include <unordered_map>
uint64_t MurmurHash3Mixer( uint64_t key ) {
key ^= (key >> 33);
key *= 0xff51afd7ed558ccd;
key ^= (key >> 33);
key *= 0xc4ceb9fe1a85ec53;
key ^= (key >> 33);
return key;
}
int main() {
uint64_t tx = 10L;
std::unordered_map<uint64_t, uint64_t> ht;
ht.insert(std::make_pair<uint64_t, uint64_t>(tx, 20));
std::cout << ht[tx] << std::endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire