Create a gist now

Instantly share code, notes, and snippets.

func DoubleHashing(hashA, hashB int64, n int) (hash int64) {
// h = hashA + n * hashBの計算
h := new(big.Int).Mul(big.NewInt(int64(n)), big.NewInt(hashB))
h = new(big.Int).Add(big.NewInt(hashA), h)
h = new(big.Int).Rem(h, big.NewInt(int64(size)))
// 余りが負の数になったときは正の余りにする
hash = h.Int64()
if hash < 0 {
hash += int64(size)
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment