Documentation ¶
Overview ¶
Package bloom implements a Bloom filter data structure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a Bloom filter, which represents a set of items and provides a probabilistic test for membership. Filter satisfies the encoding.BinaryMarshaler and BinaryUnmarshaler interfaces. The zero value represents an empty filter of size 0 that uses 0 hash values.
func New ¶
New returns a Filter of size b bytes that uses k hash values. It panics if b is not a power of 2 in the range [1, 8192] or k is not in the range [1, 16].
func (*Filter) MarshalBinary ¶
MarshalBinary marshals f into a binary form. It satisfies the encoding.BinaryMarshaler interface.
func (*Filter) MaybeContains ¶
MaybeContains reports whether item is probably in f's set. If MaybeContains returns true, a false positive is possible, but if MaybeContains returns false, item is definitely not in the set.
func (*Filter) UnmarshalBinary ¶
UnmarshalBinary unmarshals a binary representation of a Filter and stores the representation in f. If the size of the unmarshaled Filter in bytes is not a power of 2 in the range [1, 8192] or the unmarshaled number of hash values is not in the range [1, 16], UnmarshalBinary returns an error without modifying the contents of f. Otherwise, it overwrites any existing data in f and returns nil. UnmarshalBinary satisfies the encoding.BinaryUnmarshaler interface.