knuth multiplicative hash

后端 未结 4 865
一生所求
一生所求 2021-02-02 03:10

Is this a correct implementation of the Knuth multiplicative hash.

int hash(int v)
{
    v *= 2654435761;
    return v >> 32;
}

Does over

4条回答
  •  -上瘾入骨i
    2021-02-02 03:31

    Might be late, but heres a Java Implementation of Knuth's Method :

    For a hashtable of Size N :

    public long hash(int key) {
        long l = 2654435769L;
        return (key * l >> 32) % N ;
    }
    

提交回复
热议问题