bloom

package
v0.0.0-...-57ac6aa Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cap

func Cap() uint64

Cap returns the total possible capacity, or number of bits

func CheckLocations

func CheckLocations(b *BitSet, locations []uint64) bool

CheckLocations returns true if all locations are set in the BitSet, false otherwise.

func Equal

func Equal(a *BitSet, b *BitSet) bool

Equal tests the equvalence of two BitSets. False if they are of different sizes, otherwise true only if all the same bits are set

func EstimateParameters

func EstimateParameters(numItems uint64, fpRate float64) (numBits uint64, numHash uint64)

EstimateParameters estimates requirements for the number of bits and hash functions, to use in the Bloom Filter. Computed from the number of items to add and the false positive rate

func GetLocations

func GetLocations(key []byte, numHash uint64, data []byte) []uint64

GetLocations will generate a list of numHash bit locations using a cryptographic hash function keyed on a 16-byte key and the specified data

Types

type BitSet

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

BitSet is a set of bits

func From

func From(numBits uint64, buf []uint64) *BitSet

From is a constructor used to create a BitSet from an array of integers

func NewBitSet

func NewBitSet(numBits uint64) *BitSet

NewBitSet creates a new BitSet with numBits bits Parameters are forced to be at least 1

func SetLocations

func SetLocations(b *BitSet, locations []uint64) *BitSet

SetLocations will set all specified bits to 1 in the bitset

func (*BitSet) Bytes

func (b *BitSet) Bytes() []uint64

Bytes returns the raw bitset data - can be passed into From to recreate the BitSet

func (*BitSet) Clear

func (b *BitSet) Clear(i uint64) bool

Clear bit i to 0

func (*BitSet) Length

func (b *BitSet) Length() uint64

Length returns the number of bits of the BitSet

func (*BitSet) Set

func (b *BitSet) Set(i uint64) bool

Set bit i to 1

func (*BitSet) SetTo

func (b *BitSet) SetTo(i uint64, value bool) bool

SetTo sets bit i to value

func (*BitSet) Test

func (b *BitSet) Test(i uint64) bool

Test whether bit i is set.

Jump to

Keyboard shortcuts

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