Guy L. Steele Beside his work on Common Lisp and Scheme, he also published a hash function as part of JVM:
// [1]: Guy L. Steele, Jr., Doug Lea, and Christine H. Flood. 2014.
// Fast splittable pseudorandom number generators.
uint32_t splitmix32(uint32_t index, uint32_t seed) {
uint32_t z = (seed + index*0x9e3779b9);
z = (z ^ (z >> 16)) * 0x85ebca6b;
z = (z ^ (z >> 13)) * 0xc2b2ae35;
return z ^ (z >> 16);
}
compared to usual hashes, it has two arguments: the index and the seed.
The idea is to have a virtual O(1) addressable array of hashes corresponding to some seed hash.
Beside hashtables, it is useful for a lot of stuff.
The most basic use is distributing byte values over the entire 32bit or 64bit word range.
I personally use it to provide random numbers for each world cell, without storing these numbers in memory.
I also use it create random number of each world's update cycle.
It is even more useful when you have to sync hash generation across several threads or agents.
Obviously you can use any hash function to turn index into a hash, but this one is super fast (for video game use), yet gives good distributions:
https://lemire.me/blog/2017/08/22/testing-non-cryptographic-random-number-generators-my-results/ Current Mood: amused