bloomfilter

package module
v0.0.0-...-72acbd8 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: MIT Imports: 4 Imported by: 0

README

Bloomfilter

implementation of standard bloom filter algorithm

Usage:

package main

import (
	"fmt"
	"github.com/MilosSimic/bloomfilter"
)

func main() {
	bf := bloomfilter.New(300000, 0.01)
	bf.Add("Dog")
	bf.Add("Cat")

	fmt.Println("Test Dog [true]:", bf.Test("Dog"))
	fmt.Println("Test Cat [true]:", bf.Test("Cat"))
	fmt.Println("Test John[false]:", bf.Test("John"))
	fmt.Println("Test Doe[false]:", bf.Test("Doe"))

	bf.Add("Pig")
	bf.Add("Mice")
	bf.Add("John")

	fmt.Println("Test Pig [true]:", bf.Test("Pig"))
	fmt.Println("Test Mice [true]:", bf.Test("Mice"))
	fmt.Println("Test John[true]:", bf.Test("John"))
	fmt.Println("Test Mick[false]:", bf.Test("Mick"))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BloomFilter

type BloomFilter interface {
	Add(key string)
	Test(key string) bool
	Data() []byte
}

type StandardBloom

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

func New

func New(n uint, fpr float64) *StandardBloom

func (*StandardBloom) Add

func (sbf *StandardBloom) Add(key string)

func (*StandardBloom) Data

func (sbf *StandardBloom) Data() []byte

func (*StandardBloom) Test

func (sbf *StandardBloom) Test(key string) bool

Jump to

Keyboard shortcuts

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