bloomfilter

package
v0.0.0-...-3fd0ae8 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

README

Bloom Filter

A Bloom filter is a space-efficient data structure used to test whether an element is a member of a set. It can have false positives but no false negatives.

Pros: Can store additional information beyond membership, efficient space utilization. Cons: Higher false positive rate, limited support for deletion.

Use Cases:

Web caching: Web caching systems like Squid use Bloom filters to check if a requested URL is already cached, avoiding unnecessary disk lookups.

Database systems: Bloom filters can be used to speed up query processing in databases by quickly determining if a specific record exists in a large dataset without scanning the entire dataset.

Spell checking: Bloom filters can be used to store a dictionary of correctly spelled words, allowing for fast spell checking by querying the filter for a given word.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BloomFilter

type BloomFilter[T encoding.BinaryMarshaler] interface {
	Add(value T)
	Contains(value T) bool
}

type BloomFilterHash

type BloomFilterHash[T encoding.BinaryMarshaler] struct {
	// contains filtered or unexported fields
}

func NewBloomFilter

func NewBloomFilter[T encoding.BinaryMarshaler](size int, numHash int) *BloomFilterHash[T]

NewBloomFilter creates a new BloomFilter with the specified size and number of hash functions

func (*BloomFilterHash[T]) Add

func (bf *BloomFilterHash[T]) Add(element T)

Add inserts a new element into the Bloom filter

func (*BloomFilterHash[T]) Contains

func (bf *BloomFilterHash[T]) Contains(element T) bool

Contains checks if the Bloom filter possibly contains the given element

Jump to

Keyboard shortcuts

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