bloom_filter v1.0.1 BloomFilter

Bloom Filter implementation in Elixir. Bloom filters are probabilistic data structures designed to efficiently tell you whether an element is present in a set.

  ## Usage Example

    iex> f = BloomFilter.new 100, 0.001
    iex> f = BloomFilter.add(f, 42)
    iex> BloomFilter.has?(f, 42)
    true

Summary

Functions

Adds a given item to the set

Approximates the number of items in the filter

Checks whether a given item is likely to exist in the set

Creates a new bloom filter, given an estimated number of elements and a desired error rate (0.0..1)

Types

bit :: 0 | 1
hash_func :: (any -> pos_integer)
t :: %BloomFilter{bits: [bit, ...], capacity: pos_integer, error_rate: float, hash_functions: [hash_func, ...], num_bits: pos_integer}

Functions

add(bloom, item)

Specs

add(t, any) :: t

Adds a given item to the set.

count(bloom_filter)

Specs

count(t) :: float

Approximates the number of items in the filter.

has?(bloom_filter, item)

Specs

has?(t, any) :: boolean

Checks whether a given item is likely to exist in the set.

new(capacity, error_rate)

Specs

new(pos_integer, float) :: t

Creates a new bloom filter, given an estimated number of elements and a desired error rate (0.0..1).