Reputation:
I'm looking for a high-speed hashing function with good (i.e near uniform) distribution for use in a hash table implementation.
The hash table will be used exclusively for storing values with an integer key.
Can i just use the lower few bits of the integer as the hash?
e.g int key = n & 15; and create an array with 16 slots to store them.
Any recommendations?
Upvotes: 12
Views: 1666
Reputation: 148
Well, last night I made a versatile hash test (in C) which covers several top-gun hashers and 38 different keys.
You all are welcome to benchmark it at: http://www.overclock.net/t/1319572/benchmarking-the-fastest-hash-function/0_20#post_18495990
I would be glad for revealing how Intel vs AMD and Intel 12.1 compiler vs Microsoft 16 (VS2010) compiler combinations behave with your help.
Upvotes: 0
Reputation: 46
You can see here xxhash
Your mentioned hash function is very fast, but it is very bad too. If you want a "stupid" hash function maybe you can consider the modulus.
Example:
int key = item % size_of_hash_table
Upvotes: 3