Overview

PACKAGE

package bloom
import "bitbucket.org/ww/bloom"

Bloom filter. Written in 2011 by William Waites <ww@styx.org>
This is Free Software released under the terms of the GPL version
3 or later.

It is used like this:

    import (
        "bitbucket.org/ww/bloom"
        "crypto/sha256"
    )
    ...

    filter := bloom.New(sha256.New(), 1e6, 0.0001)
    filter.Add(some_byte_array)
    if filter.Has(some_byte_array) {
        ...
    }


TYPES

type BloomFilter struct {
    // contains unexported fields
}

func New(alg hash.Hash, n uint64, p float64) (b *BloomFilter)
Create a new bloom filter. The first argument is an implementation of
a hash function used to generate the k bits of the filter for each entry.
It is reset and salted on each round. The second argument, n is the
number of entries the data structure is expected to support and the
third, p, is the false positive rate that is considered acceptable.

func (bloom *BloomFilter) Add(buf []byte)
Add the byte array to the filter

func (bloom *BloomFilter) Has(buf []byte) bool
Check if the byte array may be present in the filter

func (bloom *BloomFilter) Hashes() int
Return the number of hashes used in this filter

func (bloom *BloomFilter) Size() int
Returns the size in bytes of the filter

func (bloom *BloomFilter) String() string