cuckoo

package
v0.4.9-rc9 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultHasher

func SetDefaultHasher(hasher Hasher)

Types

type Filter

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

Filter is a probabilistic counter

func Decode

func Decode(bytes []byte) (*Filter, error)

Decode returns a Cuckoofilter from a byte slice

func NewFilter

func NewFilter(capacity uint) *Filter

NewFilter returns a new cuckoofilter with a given capacity. A capacity of 1000000 is a normal default, which allocates about ~1MB on 64-bit machines.

func (*Filter) Count

func (cf *Filter) Count() uint

Count returns the number of items in the counter

func (*Filter) Delete

func (cf *Filter) Delete(data []byte) bool

Delete data from counter if exists and return if deleted or not

func (*Filter) Encode

func (cf *Filter) Encode() []byte

Encode returns a byte slice representing a Cuckoofilter

func (*Filter) Insert

func (cf *Filter) Insert(data []byte) bool

Insert inserts data into the counter and returns true upon success

func (*Filter) InsertUnique

func (cf *Filter) InsertUnique(data []byte) bool

InsertUnique inserts data into the counter if not exists and returns true upon success

func (*Filter) Lookup

func (cf *Filter) Lookup(data []byte) bool

Lookup returns true if data is in the counter

func (*Filter) Reset

func (cf *Filter) Reset()

Reset ...

type Hasher

type Hasher interface {
	Hash64([]byte) uint64
}

Jump to

Keyboard shortcuts

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