lemireHash64

Inspired by Lemire's strongly universal hashing.

  1. hash_t lemireHash64(ulong x)
    @safe nothrow pure @nogc @nogc pure nothrow @safe @nogc
    hash_t
    lemireHash64
    (
    in ulong x
    )
  2. hash_t lemireHash64(double x)

Examples

assert(lemireHash64(0) == 0UL);
assert(lemireHash64(1) == 10826341276197359097UL);
assert(lemireHash64(2) == 3205938474390199283UL);
assert(lemireHash64(0f) == 0UL);
assert(lemireHash64(1f) == 5597974336836488763);
assert(lemireHash64(2f) == 4611686018555721673UL);

See Also

https://lemire.me/blog/2018/08/15/fast-strongly-universal-64-bit-hashing-everywhere/

Instead of shifts, we use rotations so we don't lose any bits.

Added a final multiplcation with a constant for more mixing. It is most important that the lower bits are well mixed.

Meta