lemireHash32

Inspired by Lemire's strongly universal hashing.

  1. uint lemireHash32(uint x)
  2. uint lemireHash32(float x)
    @safe nothrow pure @nogc @nogc @trusted pure nothrow @nogc
    uint
    lemireHash32
    (
    in float x
    )

Examples

assert(lemireHash32(0) == 0UL);
assert(lemireHash32(1) == 3825694051);
assert(lemireHash32(2) == 3356420807);
assert(lemireHash32(0f) == 0UL);
assert(lemireHash32(1f) == 2910889945);
assert(lemireHash32(2f) == 1073805257);

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