bloomfilter

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 3 Imported by: 0

README

BloomFilter

Build Status GoDoc

BloomFilter is a simple and efficient implementation of a Bloom filter in Go.

Installation

To install the package, run:

go get github.com/beastop/bloomfilter

Usage

Creating a Bloom Filter
package main

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

func main() {
	// Create a new Bloom filter
	bloom, err := bloomfilter.New(100, 0.01)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	// Add items to the Bloom filter
	bloom.Add("foo")
	bloom.Add("bar")

	// Check if items are in the Bloom filter
	fmt.Println("foo in bloom filter:", bloom.Contains("foo"))
	fmt.Println("baz in bloom filter:", bloom.Contains("baz"))
}

Documentation

For detailed API documentation, please visit the GoDoc.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

Overview

Package bloomfilter is a lightweight implimentation of bloomfilter algorithm in pure golang.

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
}

Bloom represents a Bloom filter data structure.

func New

func New(item_count int, fp_prob float64) (*Bloom, error)

New creates a new Bloom filter with the specified item count and false positive probability. Returns a pointer to the Bloom filter and an error if any.

func (*Bloom) Add

func (b *Bloom) Add(item string)

Add inserts an item into the Bloom filter.

func (*Bloom) Contains

func (b *Bloom) Contains(item string) bool

Contains checks if an item is in the Bloom filter. Returns true if the item is probably in the filter, false otherwise.

Jump to

Keyboard shortcuts

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