Skip to content

Instantly share code, notes, and snippets.

@cipepser
Last active January 31, 2017 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cipepser/ab1072fe99b8250e0783334a6ea99c7c to your computer and use it in GitHub Desktop.
Save cipepser/ab1072fe99b8250e0783334a6ea99c7c to your computer and use it in GitHub Desktop.
func Exists(bf *BloomFilter, element string) (exists bool) {
hash := GetMD5Hash(element)
hashA := hash[:int(len(hash)/2)] // 前半
hashB := hash[int(len(hash)/2):] // 後半
i64_hashA, _ := strconv.ParseInt(hashA, 16, 64)
i64_hashB, _ := strconv.ParseInt(hashB, 16, 64)
exists = true
for i := 0; i < k; i++ {
if bf.BloomFilter[DoubleHashing(i64_hashA, i64_hashB, i)] == false {
exists = false
break
}
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment