gobloom

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

README

go-bloom-filter

A simple golang bloom filter

Contributing

You can commit PR to this repository

How to get it?
go get -u github.com/gobkc/go-bloom-filter
Quick start
package main

import (
	"github.com/gobkc/go-bloom-filter"
	"fmt"
)

func main() {
    b := gobloom.NewBloom()
    b.Add("Alple")
    b.Add(123)
    fmt.Println(b.Has("Apple"))
    fmt.Println(b.Has(123))
    fmt.Println(b.Has("orange"))
}

result:

true
true
false
100 million data unit test
=== RUN   TestBloom_Has
=== RUN   TestBloom_Has/test_has_element_1
=== RUN   TestBloom_Has/test_has_element_2
=== RUN   TestBloom_Has/test_not_has_element_1
=== RUN   TestBloom_Has/test_not_has_element_2
--- PASS: TestBloom_Has (26.73s)
    --- PASS: TestBloom_Has/test_has_element_1 (2.43s)
    --- PASS: TestBloom_Has/test_has_element_2 (0.00s)
    --- PASS: TestBloom_Has/test_not_has_element_1 (0.00s)
    --- PASS: TestBloom_Has/test_not_has_element_2 (0.00s)
PASS
ok      gobloom 26.760s
License

© Gobkc, 2023~time.Now

Released under the Apache License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bloom

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

func NewBloom

func NewBloom() *Bloom

func (*Bloom) Add

func (b *Bloom) Add(dest any)

func (*Bloom) Delete

func (b *Bloom) Delete(dest any)

func (*Bloom) Has

func (b *Bloom) Has(dest any) bool

func (*Bloom) Hash

func (b *Bloom) Hash(dest any) int64

Hash the Hash function converts "dest" to a string and returns a hash int value

Jump to

Keyboard shortcuts

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