The first-place Rust program uses this very simple low-security hash function:
impl Hasher for NaiveHasher {
fn write_u64(&mut self, i: u64) {
self.0 = i ^ i >> 7;
}
}
The second-place C program uses the exact same hash function as the Rust program, except it also truncates the result to 32 bits:
#define CUSTOM_HASH_FUNCTION(key) (khint32_t)((key) ^ (key)>>7)
The third-place C++ program uses the identity function as its hash function:
struct hash{
uint64_t operator()(const T& t)const{ return t.data; }
};
Sources:
- Rust: http://benchmarksgame.alioth.debian.org/u64q/program.php?tes...
- C: http://benchmarksgame.alioth.debian.org/u64q/program.php?tes...
- C++: http://benchmarksgame.alioth.debian.org/u64q/program.php?tes...