Documentation
¶
Overview ¶
Package bloom contains a generic bloom filter type that can be used with any comparable value.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter[T comparable] struct { // contains filtered or unexported fields }
Filter represents a space-efficient probabilistic data structure that tests whether an element is a member of a set. Once a Filter has been created, adding a new item to the set does not require any additional memory allocation.
func NewBloomFilter ¶
func NewBloomFilter[T comparable](expectedItems uint, falsePositiveRate float64) *Filter[T]
NewBloomFilter creates a new Bloom filter optimized for the expected number of items and desired false positive rate.
func (*Filter[T]) Add ¶
func (bf *Filter[T]) Add(item T)
Add inserts an item into the Bloom filter.
This method is not safe for concurrent use.
func (*Filter[T]) Contains ¶
Contains tests whether an item might be in the set. False positives are possible, but false negatives are not.
This method can be called concurrently with other calls to itself or Filter.EstimatedFalsePositiveRate, but not Filter.Add.
func (*Filter[T]) EstimatedFalsePositiveRate ¶
EstimatedFalsePositiveRate returns the current estimated false positive rate based on the number of items added.
This method can be called concurrently with other calls to Filter.Contains or itself.