美文网首页
布隆过滤器

布隆过滤器

作者: robertzhai | 来源:发表于2023-01-30 10:28 被阅读0次

bit op

//将第num位设为1即实现插入
 bf.bits[h/64] ^= 1 << (h % 64)

//判断第num是否为1,为1返回true,否则为false
 if bf.bits[h/64]&(1<<(h%64)) > 0 {
        return true
  }
var bitmap
func insert(key) {
    for h := range hashs {
        bitmap.setone(h(key))
    }
}

func lookup(key) bool {
    for h := range hashs {
        if bitmap.get(h(key)) != 1 {
            return false
        }
    }
    return true
}

ref

相关文章

网友评论

      本文标题:布隆过滤器

      本文链接:https://www.haomeiwen.com/subject/sxdphdtx.html