bloom

package module
v0.0.0-...-44d6c5c Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Overview

Package bloom implements a Bloom Filter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveSize

func DeriveSize(n int, p float64) int

DeriveSize returns the size of a filter (as a power of 2) in bits, required to hold at least n entries with a p false positive rate.

The returned value is directly suitable for use as the mLn2 parameter passed to New().

Types

type Filter

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

Filter is a bloom filter.

func New

func New(rand io.Reader, mLn2 int, p float64) (*Filter, error)

New constructs a new Filter with a filter set size 2^mLn2 bits, and false postive rate p.

func (*Filter) Entries

func (f *Filter) Entries() int

Entries returns the number of entries that have been inserted into the Filter.

func (*Filter) MaxEntries

func (f *Filter) MaxEntries() int

MaxEntries returns the maximum capacity of the Filter.

func (*Filter) Test

func (f *Filter) Test(b []byte) bool

Test tests the Filter for a given value's membership and returns true iff it is present (or a false positive).

func (*Filter) TestAndSet

func (f *Filter) TestAndSet(b []byte) bool

TestAndSet tests the Filter for a given value's membership, adds the value to the filter, and returns true iff it was present at the time of the call.

Jump to

Keyboard shortcuts

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