bloom_filters

package module
v0.0.0-...-fdf4e2c Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 2 Imported by: 0

README

Bloom Filter Implementation in Go ⚡️

Bloom filters are a probabilistic data structure that are used to test whether an element is a member of a set. This project includes a simple implementation of Bloom Filters in Go.

Features 📋

  • Quick to add elements & check membership in the Bloom Filter.
  • Memory-efficient representation of a set (at the cost of a small false positive rate).
  • The false positive rate decreases as we increase the filter's size or the number of hash functions.

Setup 🚀

First, make sure you have Go installed on your machine. If you do not have it installed, you can download it from the official website here.

To experiment with the Bloom Filter, clone the project.

git clone  https://github.com/pratikpandey21/bloom_filters.git

Understand how the bloom filters accuracy changes with, check out the tests and run them to see the results -

go test ./...

Usage 💻

You can use the bloom filter in your own code.

import "github.com/pratikpandey21/bloom_filters"

bf := NewBloomFilter(size, hashCount)
// Add an element
bf.Add("element")
// Check membership
exists := bf.Contains("element")
fmt.Println(exists) 

Contributing 🤝

Contributions, issues, and feature requests are welcome! See CONTRIBUTING.md for more information.

License 🏷️

This project is licensed under the terms of the MIT license. See LICENSE for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BloomFilter

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

func NewBloomFilter

func NewBloomFilter(size, hashCount int) *BloomFilter

func (*BloomFilter) Add

func (bf *BloomFilter) Add(str string)

func (*BloomFilter) Contains

func (bf *BloomFilter) Contains(str string) bool

Jump to

Keyboard shortcuts

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