bloomfilter

package module
v0.0.0-...-6f08307 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 5 Imported by: 0

README

Bloom Filter Implementation in Go

I have implemented a Bloom filter data structure in Go. A Bloom filter is a space-efficient probabilistic data structure used to test whether an element is a member of a set.

Features

  • Thread-safe operations
  • Customizable size and number of hash functions
  • Estimated false positive rate calculation
  • Union operation for combining filters

Running the Demo

To run the demonstration program:

go run cmd/main.go

Running Tests

To run the unit tests:

go test ./...

License

This project is available under the MIT License.

Documentation

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
}

func Deserialize

func Deserialize(data []byte) *BloomFilter

func New

func New(size uint, numHashes int) *BloomFilter

func (*BloomFilter) Add

func (bf *BloomFilter) Add(item []byte)

func (*BloomFilter) Contains

func (bf *BloomFilter) Contains(item []byte) bool

func (*BloomFilter) Count

func (bf *BloomFilter) Count() uint

func (*BloomFilter) EstimatedFalsePositiveRate

func (bf *BloomFilter) EstimatedFalsePositiveRate() float64

func (*BloomFilter) OptimalNumHashes

func (bf *BloomFilter) OptimalNumHashes(expectedElements uint) int

func (*BloomFilter) Reset

func (bf *BloomFilter) Reset()

func (*BloomFilter) Serialize

func (bf *BloomFilter) Serialize() []byte

func (*BloomFilter) Union

func (bf *BloomFilter) Union(other *BloomFilter) *BloomFilter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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