Skip to content

Commit 66dc0a3

Browse files
committed
Simplify examples
1 parent 7f8edde commit 66dc0a3

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

example_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,33 @@ func Example_basics() {
2828

2929
// Count the number of false positives.
3030
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 := 1000
31+
// Create a Bloom filter with room for 10000 elements
32+
// at a false-positives rate less than 1/100.
33+
n := 10000
3434
p := 100
3535
filter := bloom.New(n, p)
3636

3737
// Add n random strings.
3838
for i := 0; i < n; i++ {
39-
filter.Add(strconv.FormatUint(rand.Uint64(), 10))
39+
filter.Add(strconv.Itoa(rand.Int()))
4040
}
4141

4242
// Do n random lookups and count the (mostly accidental) hits.
4343
// It shouldn't be much more than n/p, and hopefully less.
4444
count := 0
4545
for i := 0; i < n; i++ {
46-
if filter.Test(strconv.FormatUint(rand.Uint64(), 10)) {
46+
if filter.Test(strconv.Itoa(rand.Int())) {
4747
count++
4848
}
4949
}
5050
fmt.Println(count, "mistakes were made.")
51-
// Output: 1 mistakes were made.
51+
// Output: 26 mistakes were made.
5252
}
5353

5454
// Compute the intersection and union of two filters.
5555
func ExampleFilter_And() {
56-
// Create two Bloom filter with room for n elements
57-
// at a false-positives rate less than 1/p.
56+
// Create two Bloom filter with room for 1000 elements
57+
// at a false-positives rate less than 1/100.
5858
n := 1000
5959
p := 100
6060
f1, f2 := bloom.New(n, p), bloom.New(n, p)

0 commit comments

Comments
 (0)