bloom

package
v0.0.0-...-eb64f0e Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 4 Imported by: 0

README

About Bloom Filter

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

Bucket is a bit wise container used in bloom filters.

func NewBucket

func NewBucket(m uint) *Bucket

NewBucket creates a empty bucket with at least m bits.

func (*Bucket) Get

func (b *Bucket) Get(pos uint) uint

Get the bit at position.

func (*Bucket) Set

func (b *Bucket) Set(pos uint)

Set the bit at position pos.

type Classic

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

Classic implements a classic Bloom Filter.

func NewClassic

func NewClassic(n uint, p float64) *Classic

NewClassic returns a classic bloom filter.

func (*Classic) Add

func (c *Classic) Add(key []byte) Filter

Add - Filter interface implementation.

func (*Classic) Contains

func (c *Classic) Contains(key []byte) bool

Contains - Filter interface implementation.

type Count

type Count struct {
	Bucket *CountBucket
	// contains filtered or unexported fields
}

Count - a implement of count bloom filter.

func NewCount

func NewCount(n uint, p float64) *Count

NewCount - make a count bloom.

func (*Count) Add

func (c *Count) Add(key []byte) Filter

Add - Filter interface implementation.

func (*Count) Contains

func (c *Count) Contains(key []byte) bool

Contains - Filter interface implementation.

func (*Count) Delete

func (c *Count) Delete(key []byte)

Delete - Delete a element from bucket.

type CountBucket

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

CountBucket is a bit wise container used in count bloom filters.

func NewCountBucket

func NewCountBucket(m uint) *CountBucket

NewCountBucket creates a empty Bucket with at least m bits.

func (*CountBucket) Get

func (b *CountBucket) Get(pos uint) uint

Get the bit at position.

func (*CountBucket) Remove

func (b *CountBucket) Remove(pos uint)

Remove - decrease the count of one element.

func (*CountBucket) Set

func (b *CountBucket) Set(pos uint)

Set the bit at position pos.

type Filter

type Filter interface {
	Contains([]byte) bool
	Add([]byte) Filter
}

Filter is a probabilistic data structure which is used to test whether an element in a set or not.

Jump to

Keyboard shortcuts

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