File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package bloom_test
33import (
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.
5429func ExampleFilter_Union () {
5530 // Create two Bloom filters, each with room for 1000 elements
Original file line number Diff line number Diff line change 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+ //
5257package bloom
5358
5459import (
You can’t perform that action at this time.
0 commit comments