@@ -225,7 +225,9 @@ func (f *BloomFilter) TestLocations(locs []uint64) bool {
225225 return true
226226}
227227
228- // TestAndAdd is the equivalent to calling Test(data) then Add(data).
228+ // TestAndAdd is equivalent to calling Test(data) then Add(data).
229+ // The filter is written to unconditionnally: even if the element is present,
230+ // the corresponding bits are still set. See also TestOrAdd.
229231// Returns the result of Test.
230232func (f * BloomFilter ) TestAndAdd (data []byte ) bool {
231233 present := true
@@ -241,12 +243,15 @@ func (f *BloomFilter) TestAndAdd(data []byte) bool {
241243}
242244
243245// TestAndAddString is the equivalent to calling Test(string) then Add(string).
246+ // The filter is written to unconditionnally: even if the string is present,
247+ // the corresponding bits are still set. See also TestOrAdd.
244248// Returns the result of Test.
245249func (f * BloomFilter ) TestAndAddString (data string ) bool {
246250 return f .TestAndAdd ([]byte (data ))
247251}
248252
249- // TestOrAdd is the equivalent to calling Test(data) then if not present Add(data).
253+ // TestOrAdd is equivalent to calling Test(data) then if not present Add(data).
254+ // If the element is already in the filter, then the filter is unchanged.
250255// Returns the result of Test.
251256func (f * BloomFilter ) TestOrAdd (data []byte ) bool {
252257 present := true
@@ -262,6 +267,7 @@ func (f *BloomFilter) TestOrAdd(data []byte) bool {
262267}
263268
264269// TestOrAddString is the equivalent to calling Test(string) then if not present Add(string).
270+ // If the string is already in the filter, then the filter is unchanged.
265271// Returns the result of Test.
266272func (f * BloomFilter ) TestOrAddString (data string ) bool {
267273 return f .TestOrAdd ([]byte (data ))
0 commit comments