本文整理匯總了Golang中hash.Hash64.Reset方法的典型用法代碼示例。如果您正苦於以下問題:Golang Hash64.Reset方法的具體用法?Golang Hash64.Reset怎麽用?Golang Hash64.Reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hash.Hash64
的用法示例。
在下文中一共展示了Hash64.Reset方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: benchmarkHash
func benchmarkHash(b *testing.B, h hash.Hash64) {
uids := getUids(b.N)
var s uint64
b.ResetTimer()
for i := 0; i < b.N; i++ {
h.Reset()
io.WriteString(h, uids[i])
s = h.Sum64()
}
result = s
}
示例2: hashUpdateOrdered
func hashUpdateOrdered(h hash.Hash64, a, b uint64) uint64 {
// For ordered updates, use a real hash function
h.Reset()
// We just panic if the binary writes fail because we are writing
// an int64 which should never be fail-able.
e1 := binary.Write(h, binary.LittleEndian, a)
e2 := binary.Write(h, binary.LittleEndian, b)
if e1 != nil {
panic(e1)
}
if e2 != nil {
panic(e2)
}
return h.Sum64()
}
示例3: testCollissions
func testCollissions(t *testing.T, h hash.Hash64) {
uids := getUids(uidSize)
results := make(map[uint64]bool)
cols := 0
for i := 0; i < uidSize; i++ {
h.Reset()
io.WriteString(h, uids[i])
s := h.Sum64()
if _, col := results[s]; col {
cols += 1
} else {
results[s] = true
}
}
if cols > 0 {
t.Errorf("Found %v collissions for uidSize %v\n", cols, uidSize)
}
}
示例4: Hash64
// Hash64 is a convenience method for hashing a string against a hash.Hash64
func Hash64(s string, h hash.Hash64) uint64 {
h.Reset()
h.Write([]byte(s))
return h.Sum64()
}
示例5: hashKernel
// hashKernel returns the upper and lower base hash values from which the k
// hashes are derived.
func hashKernel(data []byte, hash hash.Hash64) (uint32, uint32) {
hash.Write(data)
sum := hash.Sum(nil)
hash.Reset()
return binary.BigEndian.Uint32(sum[4:8]), binary.BigEndian.Uint32(sum[0:4])
}