@@ -122,43 +122,12 @@ func (f *Filter) Count() int64 {
122122 return f .count
123123}
124124
125- // And returns a new Bloom filter that consists of all elements
126- // that belong to both f1 and f2. The two filters must be of
127- // the same size and have the same false-positives rate.
128- //
129- // The false-positive rate of the resulting filter is bounded by
130- // the maximum false-positive rate of f1 and f2, but it may be larger
131- // than the rate of the filter created from scratch using
132- // the intersection of the two sets.
133- func (f1 * Filter ) And (f2 * Filter ) * Filter {
134- if len (f1 .data ) != len (f2 .data ) || f1 .lookups != f2 .lookups {
135- panic ("operation requires filters of the same type" )
136- }
137- len := len (f1 .data )
138- res := & Filter {
139- data : make ([]uint64 , len ),
140- lookups : f1 .lookups ,
141- }
142- bitCount := 0
143- for i := 0 ; i < len ; i ++ {
144- w := f1 .data [i ] & f2 .data [i ]
145- res .data [i ] = w
146- bitCount += count (w )
147- }
148- // Estimate the number of elements from the bitCount.
149- m := 64 * float64 (len )
150- bits := float64 (bitCount )
151- n := m / float64 (f1 .lookups ) * math .Log (m / (m - bits ))
152- res .count = int64 (n )
153- return res
154- }
155-
156125// Or returns a new Bloom filter that consists of all elements
157126// that belong to either f1 or f2. The two filters must be of
158- // the same size and have the same false-positives rate.
127+ // the same size n and have the same false-positives rate p .
159128//
160- // The resulting filter is the same as the filter created from scratch
161- // using the union of the two sets.
129+ // The resulting filter is the same as the filter created
130+ // from scratch using the union of the two sets.
162131func (f1 * Filter ) Or (f2 * Filter ) * Filter {
163132 if len (f1 .data ) != len (f2 .data ) || f1 .lookups != f2 .lookups {
164133 panic ("operation requires filters of the same type" )
0 commit comments