33// Bloom filters
44//
55// A Bloom filter is a space-efficient probabilistic data structure
6- // used to test set membership. A member query returns either
7- // ”likely in set ” or ”definitely not in set ”. Only false positives
8- // may occur: an element that has been added to the filter
9- // will be identified as ”likely in set ”.
6+ // used to test set membership. A member test returns either
7+ // ”likely member ” or ”definitely not a member ”. Only false positives
8+ // can occur: an element that has been added to the filter
9+ // will be identified as ”likely member ”.
1010//
11- // Elements can be added, but not removed. With more elements in the set ,
11+ // Elements can be added, but not removed. With more elements in the filter ,
1212// the probability of false positives increases.
1313//
1414// Implementation
1515//
1616// A full filter with a false-positives rate of 1/p uses roughly
1717// 0.26ln(p) bytes per element and performs ⌈1.4ln(p)⌉ bit array lookups
18- // per query :
18+ // per test :
1919//
2020// p bytes lookups
2121// -------------------------
3030// 1024 1.8 10
3131//
3232// This implementation is not intended for cryptographic use.
33- // Each membership query makes a single call to a 128-bit MurmurHash3 function.
33+ // Each membership test makes a single call to a 128-bit MurmurHash3 function.
3434// This saves on hashing without increasing the false-positives
3535// probability as shown by Kirsch and Mitzenmacher.
3636//
@@ -95,8 +95,8 @@ func (f *Filter) Add(s string) bool {
9595 return f .AddByte (b )
9696}
9797
98- // LikelyByte tells if b is a likely member of this filter.
99- func (f * Filter ) LikelyByte (b []byte ) bool {
98+ // TestByte tells if b is a likely member of this filter.
99+ func (f * Filter ) TestByte (b []byte ) bool {
100100 h1 , h2 := murmur .hash (b )
101101 trunc := uint64 (len (f .data ))<< shift - 1
102102 for i := f .lookups ; i > 0 ; i -- {
@@ -110,11 +110,11 @@ func (f *Filter) LikelyByte(b []byte) bool {
110110 return true
111111}
112112
113- // Likely tells if s is a likely member of this filter.
114- func (f * Filter ) Likely (s string ) bool {
113+ // Test tells if s is a likely member of this filter.
114+ func (f * Filter ) Test (s string ) bool {
115115 b := make ([]byte , len (s ))
116116 copy (b , s )
117- return f .LikelyByte (b )
117+ return f .TestByte (b )
118118}
119119
120120// Count returns an estimate of the number of unique elements added to this filter.
0 commit comments