Skip to content

Commit 641687e

Browse files
committed
Remove counting example
1 parent abc8c52 commit 641687e

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

example_test.go

-25
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package bloom_test
33
import (
44
"fmt"
55
"github.com/yourbasic/bloom"
6-
"math/rand"
76
"strconv"
87
)
98

@@ -26,30 +25,6 @@ func Example_basics() {
2625
// Output: https://rascal.com seems to be shady.
2726
}
2827

29-
// Estimate the number of false positives.
30-
func Example_falsePositives() {
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
34-
filter := bloom.New(n, p)
35-
36-
// Add n random strings.
37-
for i := 0; i < n; i++ {
38-
filter.Add(strconv.Itoa(rand.Int()))
39-
}
40-
41-
// Do n random lookups and count the (mostly accidental) hits.
42-
// It shouldn't be much more than n/p, and hopefully less.
43-
count := 0
44-
for i := 0; i < n; i++ {
45-
if filter.Test(strconv.Itoa(rand.Int())) {
46-
count++
47-
}
48-
}
49-
fmt.Println(count, "mistakes were made.")
50-
// Output: 26 mistakes were made.
51-
}
52-
5328
// Compute the union of two filters.
5429
func ExampleFilter_Union() {
5530
// Create two Bloom filters, each with room for 1000 elements

filter.go

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
// The internal data representation is different for big-endian
5050
// and little-endian machines.
5151
//
52+
// Typical use case
53+
//
54+
// The Basics example contains a typcial use case:
55+
// a blacklist of shady websites.
56+
//
5257
package bloom
5358

5459
import (

0 commit comments

Comments
 (0)