mirror of
https://github.com/tursom/GoCollections.git
synced 2026-08-19 05:23:29 +08:00
bloom support merge operation
This commit is contained in:
@@ -116,7 +116,21 @@ func Unmarshal(data []byte) *Bloom {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bloom) Merge(bitMap []byte) bool {
|
||||
func (b *Bloom) Merge(t *Bloom) bool {
|
||||
if b.k != t.k {
|
||||
return false
|
||||
} else if len(b.m) != len(t.m) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i := range b.m {
|
||||
b.m[i] |= t.m[i]
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *Bloom) MergeBM(bitMap []byte) bool {
|
||||
if len(b.m) != len(bitMap) {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user