Class BloomFilter

  • All Implemented Interfaces:
    Membership

    public final class BloomFilter
    extends Object
    implements Membership
    A Bloom filter is a space and time efficient probabilistic data structure that is used to test whether an element is a member of a set. False positives are possible, but false negatives are not. Elements can be added to the set, but not removed. The more elements that are added the higher the probability of false positives. While risking false positives, Bloom filters have a space advantage over other data structures for representing sets by not storing the items.
    • Method Detail

      • ensureCapacity

        public void ensureCapacity​(@org.checkerframework.checker.index.qual.NonNegative long expectedInsertions,
                                   @org.checkerframework.checker.index.qual.NonNegative double fpp)
        Initializes and increases the capacity of this BloomFilter instance, if necessary, to ensure that it can accurately estimate the membership of elements given the expected number of insertions. This operation forgets all previous memberships when resizing.
        Parameters:
        expectedInsertions - the number of expected insertions
        fpp - the false positive probability, where 0.0 > fpp < 1.0
      • mightContain

        public boolean mightContain​(long e)
        Description copied from interface: Membership
        Returns if the element might have been put in this Bloom filter, false if this is definitely not the case.
        Specified by:
        mightContain in interface Membership
        Parameters:
        e - the element whose presence is to be tested
        Returns:
        if the element might be present
      • clear

        public void clear()
        Description copied from interface: Membership
        Removes the elements from this collection.
        Specified by:
        clear in interface Membership
      • put

        public boolean put​(long e)
        Description copied from interface: Membership
        Puts an element into this collection so that subsequent queries with the same element will return true.
        Specified by:
        put in interface Membership
        Parameters:
        e - the element to add
        Returns:
        if the membership changed as a result of this operation