bloomfilter

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package bloomfilter

(C) Copyright Starskey

Original Author: Alex Gaetano Padula

Licensed under the Mozilla Public License, v. 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.mozilla.org/en-US/MPL/2.0/

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BloomFilter

type BloomFilter struct {
	Bitset []int8 // Bitset, each int8 can store 8 bits
	Size   uint   // Size of the bit array
	// contains filtered or unexported fields
}

BloomFilter struct represents a Bloom filter

func Deserialize

func Deserialize(data []byte) (*BloomFilter, error)

Deserialize reconstructs a BloomFilter from a byte slice

func New

func New(expectedItems uint, falsePositiveRate float64) (*BloomFilter, error)

New creates a new Bloom filter with an expected number of items and false positive rate

func (*BloomFilter) Add

func (bf *BloomFilter) Add(data []byte)

Add adds an item to the Bloom filter

func (*BloomFilter) Contains

func (bf *BloomFilter) Contains(data []byte) bool

Contains checks if an item might exist in the Bloom filter

func (*BloomFilter) Serialize

func (bf *BloomFilter) Serialize() ([]byte, error)

Serialize converts the BloomFilter to a byte slice

Jump to

Keyboard shortcuts

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