BloomFilter (bloom_filter v1.1.0)

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

Link to this section 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).

Link to this section Types

Specs

bit() :: 0 | 1

Specs

hash_func() :: (any() -> pos_integer())

Specs

t() :: %BloomFilter{
  bits: [bit(), ...],
  capacity: pos_integer(),
  error_rate: float(),
  hash_functions: [hash_func(), ...],
  num_bits: pos_integer()
}

Link to this section Functions

Link to this function

add(bloom, item)

Specs

add(t(), any()) :: t()

Adds a given item to the set.

Link to this function

count(bloom_filter)

Specs

count(t()) :: float()

Approximates the number of items in the filter.

Link to this function

has?(bloom_filter, item)

Specs

has?(t(), any()) :: boolean()

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

Link to this function

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).