Skip to content

Commit 720d1ae

Browse files
committed
Rename Or -> Union
1 parent 0d2fa99 commit 720d1ae

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

example_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strconv"
88
)
99

10-
// Create and use a Bloom filter.
10+
// Build a blacklist of shady websites.
1111
func Example_basics() {
1212
// Create a Bloom filter with room for 10000 elements
1313
// at a false-positives rate less than 0.5 percent.
@@ -28,10 +28,9 @@ func Example_basics() {
2828

2929
// Count the number of false positives.
3030
func Example_falsePositives() {
31-
// Create a Bloom filter with room for 10000 elements
32-
// at a false-positives rate less than 1/100.
33-
n := 10000
34-
p := 100
31+
// Create a Bloom filter with room for n elements
32+
// at a false-positives rate less than 1/p.
33+
n, p := 10000, 100
3534
filter := bloom.New(n, p)
3635

3736
// Add n random strings.
@@ -70,6 +69,6 @@ func ExampleFilter_Or() {
7069
}
7170

7271
// Compute the approximate size of f1 ∪ f2.
73-
fmt.Println("f1 ∪ f2:", f1.Or(f2).Count())
72+
fmt.Println("f1 ∪ f2:", f1.Union(f2).Count())
7473
// Output: f1 ∪ f2: 505
7574
}

filter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ func (f *Filter) Count() int64 {
122122
return f.count
123123
}
124124

125-
// Or returns a new Bloom filter that consists of all elements
125+
// Union returns a new Bloom filter that consists of all elements
126126
// that belong to either f1 or f2. The two filters must be of
127127
// the same size n and have the same false-positives rate p.
128128
//
129129
// The resulting filter is the same as the filter created
130130
// from scratch using the union of the two sets.
131-
func (f1 *Filter) Or(f2 *Filter) *Filter {
131+
func (f1 *Filter) Union(f2 *Filter) *Filter {
132132
if len(f1.data) != len(f2.data) || f1.lookups != f2.lookups {
133133
panic("operation requires filters of the same type")
134134
}

filter_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestFilter(t *testing.T) {
5858
}
5959
}
6060

61-
func TestOr(t *testing.T) {
61+
func TestUnion(t *testing.T) {
6262
s1 := "asöldkgjaösldkgaösldkasldgjkaösldkgjöasgkdjg"
6363
s2 := "elasödlnkgaölsdkfgaölsdkjfaölsdkgaölskgnaösl"
6464
s3 := "aölsdgkaösldkgaösldkgjaölsdkjgaölsdkgjaösldk"
@@ -69,7 +69,7 @@ func TestOr(t *testing.T) {
6969
f1.Add(s2)
7070
f2.Add(s2)
7171
f2.Add(s3)
72-
or := f1.Or(f2)
72+
or := f1.Union(f2)
7373
member := or.Test(s1)
7474
if !member {
7575
t.Errorf("or.Test(s1) = %v; want true\n", member)
@@ -126,13 +126,13 @@ func BenchmarkTestByte(b *testing.B) {
126126
}
127127
}
128128

129-
func BenchmarkTestOr(b *testing.B) {
129+
func BenchmarkTestUnion(b *testing.B) {
130130
n := 1000
131131
b.StopTimer()
132132
f1 := New(n, 200)
133133
f2 := New(n, 200)
134134
b.StartTimer()
135135
for i := 0; i < b.N; i++ {
136-
_ = f1.Or(f2)
136+
_ = f1.Union(f2)
137137
}
138138
}

0 commit comments

Comments
 (0)