bloom

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bloom

type Bloom struct {
	// contains filtered or unexported fields
}

Bloom represents a bloom filter. It holds the filter itself, the hashing functions that must be applied to values that are added to the filter and a mutex to handle concurrent accesses to the filter

func NewDefaultFilter

func NewDefaultFilter() *Bloom

NewDefaultFilter returns a new Bloom object with a filter size of 2048 bytes and implementations of blake2b, sha3-keccak and fnv128a hashing functions

func NewFilter

func NewFilter(size uint, h []hashing.Hasher) (*Bloom, error)

NewFilter returns a new Bloom object with the given size and hashing functions implementation. It returns an error if there are no hashing functions, or if the size of the filter is too small

func (*Bloom) Add

func (b *Bloom) Add(data []byte)

Add sets the bits that correspond to the hashes of the data

func (*Bloom) Clear

func (b *Bloom) Clear()

Clear resets the bits of the bloom filter

func (*Bloom) IsInterfaceNil

func (b *Bloom) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Bloom) MayContain

func (b *Bloom) MayContain(data []byte) bool

MayContain checks if the bits that correspond to the hashes of the data are set. If all the bits are set, it returns true, otherwise it returns false

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL