Documentation ¶
Overview ¶
Package bloom is an implementation of Bloom filter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BloomFilter ¶
type BloomFilter struct {
// contains filtered or unexported fields
}
BloomFilter is a datastructure to tell if a element is present in a set. The BloomFilter trades accuracy for space. The contains method returns false if the element is definitely not present but true if the element might be in the set.
func NewBloomFilter ¶
func NewBloomFilter(maxSize uint32, maxTolerance float64, seed uint32) (*BloomFilter, error)
NewBloomFilter allocates a new BloomFilter parameterised by the arguments.
maxSize - the maximum number of elements the filter is expected to hold (must be > 0) maxTolerance - the expected accuracy (a sensible default is 0.01) seed - the seed to use for hashFunctions.
func (*BloomFilter) Contains ¶
func (bf *BloomFilter) Contains(key []byte) bool
Contains returns false if the key is definitely not contained in the set else returns true if the key might be in the set.
func (*BloomFilter) FalsePositiveProbability ¶
func (bf *BloomFilter) FalsePositiveProbability() float64
FalsePositiveProbability returns the probability of a false positive being returned by BloomFilter.
func (*BloomFilter) Insert ¶
func (bf *BloomFilter) Insert(key []byte)
Insert adds the key to the set in the BloomFilter.