Created
October 3, 2017 09:05
-
-
Save l-bat/d8d5a097b3d1e6dbe87d6e020fa10c8a to your computer and use it in GitHub Desktop.
cash to hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace std { | |
template<> | |
class hash<Key> { | |
public: | |
size_t operator()(const Key& s) const | |
{ | |
mt19937_64 generator{random_device()()}; | |
uniform_int_distribution<unsigned> distribution(1, 8); | |
unsigned i1 = static_cast<const unsigned &>(s.second.first * 1000); | |
unsigned i2 = static_cast<const unsigned &>(s.second.second * 1000); | |
unsigned i3 = static_cast<const unsigned &>(s.first.length()); | |
unsigned hash1_1 = 0x82568325; | |
unsigned hash1_2 = 0x47626962; | |
unsigned hash1_3 = 0x57583014; | |
hash1_1+=hash1_2*8+_rotr(i1, distribution(generator)); | |
hash1_2+=hash1_1*8+_rotr(i2, distribution(generator)); | |
hash1_3= (hash1_1 * hash1_2)+_rotr(i3, distribution(generator)); | |
// hash1_1+=hash1_2*8+_rotr(i1, 8); | |
// hash1_2+=hash1_1*8+_rotr(i2, 8); | |
// hash1_3= (hash1_1 * hash1_2)+_rotr(i3, 8); | |
unsigned hash1 = hash1_3 ^ hash1_1 ^ hash1_2; | |
return hash1; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment