Bloom Filter data structure A Bloom filter is a space-efficient probabilistic data structure used to test whether an element is a member of a set. False positive matches are possible, but false negatives are not.

Example

const bloom = new BloomFilter(1000, 3);
bloom.add("apple");
bloom.contains("apple"); // true (definitely added)
bloom.contains("banana"); // false (probably not added)

Hierarchy

  • BloomFilter

Constructors

Properties

bitArray: boolean[]
hashCount: number
size: number

Methods

  • Checks if an element might be in the set Returns true if the element might be present (could be false positive) Returns false if the element is definitely not present

    Parameters

    • item: string

    Returns boolean

  • Estimates the false positive probability

    Parameters

    • itemsAdded: number

    Returns number

  • Hash function using DJB2 algorithm with seed

    Parameters

    • item: string
    • seed: number

    Returns number

Generated using TypeDoc