Documentation ¶
Index ¶
- Constants
- type BloomFilter
- func (bf *BloomFilter) Contains(item interface{}) (bool, error)
- func (bf *BloomFilter) FalsePositiveRate() (float64, error)
- func (bf *BloomFilter) GetArray() ([]byte, error)
- func (bf *BloomFilter) GetHashFunctions() (uint8, error)
- func (bf *BloomFilter) Insert(item interface{}) error
- func (bf1 *BloomFilter) Intersection(bf2 *BloomFilter) (*BloomFilter, error)
- func (bf *BloomFilter) NumberOfItems() (int, error)
- func (bf1 *BloomFilter) Union(bf2 *BloomFilter) (*BloomFilter, error)
Constants ¶
const SIZEOFUINT8 = 8
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BloomFilter ¶
type BloomFilter struct {
// contains filtered or unexported fields
}
BloomFilter represents a probabilistic data structure used for membership testing.
func NewBloomFilter ¶
func NewBloomFilter(length uint16, hashFunctions uint8) (*BloomFilter, error)
New creates and initializes a new BloomFilter with the specified length and number of hash functions.
func (*BloomFilter) Contains ¶
func (bf *BloomFilter) Contains(item interface{}) (bool, error)
Contains checks if an item is possibly in the BloomFilter. The item parameter can be of any type as it is a generic interface{}. Return true if it might be in the filter, false if it definitely isn't.
func (*BloomFilter) FalsePositiveRate ¶
func (bf *BloomFilter) FalsePositiveRate() (float64, error)
FalsePositiveRate returns the false positive rate based on the number of hash functions and the filter size of the BloomFilter.
func (*BloomFilter) GetArray ¶
func (bf *BloomFilter) GetArray() ([]byte, error)
GetArray retrieves the array associated with the BloomFilter structure
func (*BloomFilter) GetHashFunctions ¶
func (bf *BloomFilter) GetHashFunctions() (uint8, error)
GetHashFunctions retrieves the number of hash functions associated with the BloomFilter structure
func (*BloomFilter) Insert ¶
func (bf *BloomFilter) Insert(item interface{}) error
Insert adds an item to the BloomFilter. The item parameter can be of any type as it is a generic interface{}.
func (*BloomFilter) Intersection ¶
func (bf1 *BloomFilter) Intersection(bf2 *BloomFilter) (*BloomFilter, error)
Intersection creates a new Bloom Filter representing the intersection of two Bloom Filters.
func (*BloomFilter) NumberOfItems ¶
func (bf *BloomFilter) NumberOfItems() (int, error)
NumberOfItems estimates the number of items present inside the bloom filter
func (*BloomFilter) Union ¶
func (bf1 *BloomFilter) Union(bf2 *BloomFilter) (*BloomFilter, error)
Union creates a new Bloom Filter representing the union of two Bloom Filters.