I have a hash table whose keys have 64-bit values. The size of the table may have a different length of 2, for example 2, 4, 8, etc. I want the hash table function to work well for such cases, that is, it has minimal collisions. As an example, if I need a table size of 32, the hash function should create values ββfrom 0 to 31 with minimal collision for 64-bit inputs.
I found good solutions for 32-bit inputs, but none of the 64-bit inputs have been.
For 32-bit keys, I use this function
#define hash32(x) ( (x) * 2654435761 ) unsigned int getHashKey( unsigned long x ) { return hash32(x) >> ( 32 - h_bits ); }
It would be interesting to have hash32 (x) the equivalent of 64 bits.
source share