oppobloom

package module
v0.0.0-...-54a9680 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package oppobloom implements a filter data structure that may report false negatives but no false positives.

Index

Constants

This section is empty.

Variables

View Source
var ErrSizeTooLarge = errors.New("oppobloom: size given too large to round to a power of 2")
View Source
var ErrSizeTooSmall = errors.New("oppobloom: filter cannot have a zero or negative size")
View Source
var MaxFilterSize = 1 << 30

Functions

This section is empty.

Types

type Filter

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

func NewFilter

func NewFilter(size int) (*Filter, error)

func (*Filter) ContainsAndAdd

func (f *Filter) ContainsAndAdd(id []byte) bool

ContainsAndAdd adds the id to the filter and returns true if the id was already present in it. False positives are not possible but false negatives are (that is, this function will never incorrectly return true but may incorrectly return false). False negatives occur when the given id has been previously seen, but in the time since that id was last passed to this method, a different id that hashed to the same index in the filter was added.

ContainsAndAdd is thread-safe.

func (*Filter) Size

func (f *Filter) Size() int

Jump to

Keyboard shortcuts

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