Class CountingBloomFilter<E>

java.lang.Object
org.drasyl.util.BloomFilter<E>
org.drasyl.util.CountingBloomFilter<E>
Type Parameters:
E - the type of elements maintained by this set
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public class CountingBloomFilter<E> extends BloomFilter<E>
A special BloomFilter that allows you to remove elements.
  • Constructor Details

    • CountingBloomFilter

      protected CountingBloomFilter(BloomFilter.Parameters parameters, Function<E,byte[]> bytesSupplier, BitSet bitSet, int countingBits)
    • CountingBloomFilter

      protected CountingBloomFilter(BloomFilter.Parameters parameters, Function<E,byte[]> bytesSupplier, int countingBits)
    • CountingBloomFilter

      public CountingBloomFilter(int n, double p, int m, int k, Function<E,byte[]> bytesSupplier, BitSet bitSet, int countingBits)
      Create a new bloom filter. Make sure to leave one parameter 0 as it must be derived from the other parameters.

      Visit Bloom Filter Calculator to get more information about the implications/calculation of these parameters.

      If m is not a multiple of MurmurHash3 x86 32-bit hash, this bloom filter is subject of the "modulo bias" effect.

      Parameters:
      n - Number of items in the filter. If 0, this value is derived from p, m, and k
      p - Probability of false positives, fraction between 0 and 1. If 0, this value is derived from n, m, and k
      m - Number of bits in the filter. If 0, this value is derived from n and p
      k - Number of hash functions. If 0, this value is derived from m and n
      bytesSupplier - a Function that convert objects of type E to byte[] arrays
      bitSet - BitSet holding this bloom filter's state. Caller must ensure that it has the correct size.
      countingBits - number to bits used for the counter
      Throws:
      IllegalArgumentException - if one parameter is not 0 or p is not between 0 and 1
      NullPointerException - if bytesSupplier is null
    • CountingBloomFilter

      public CountingBloomFilter(int n, double p, int m, int k, Function<E,byte[]> bytesSupplier, int countingBits)
      Create a new bloom filter. Make sure to leave one parameter 0 as it must be derived from the other parameters.

      Visit Bloom Filter Calculator to get more information about the implications/calculation of these parameters.

      If m is not a multiple of MurmurHash3 x86 32-bit hash, this bloom filter is subject of the "modulo bias" effect.

      Parameters:
      n - Number of items in the filter. If 0, this value is derived from p, m, and k
      p - Probability of false positives, fraction between 0 and 1. If 0, this value is derived from n, m, and k
      m - Number of bits in the filter. If 0, this value is derived from n and p
      k - Number of hash functions. If 0, this value is derived from m and n
      bytesSupplier - a Function that convert objects of type E to byte[] arrays
      countingBits - number to bits used for the counter
      Throws:
      IllegalArgumentException - if one parameter is not 0 or p is not between 0 and 1
      NullPointerException - if bytesSupplier is null
    • CountingBloomFilter

      public CountingBloomFilter(int n, double p, int m, int k, Function<E,byte[]> bytesSupplier, BitSet bitSet)
      Create a new counting bloom filter with Short.BYTES * 8 bits reserved for the counters. Make sure to leave one parameter 0 as it must be derived from the other parameters.

      Visit Bloom Filter Calculator to get more information about the implications/calculation of these parameters.

      Parameters:
      n - Number of items in the filter
      p - Probability of false positives, fraction between 0 and 1
      m - Number of bits in the filter. If 0, this value is derived from n and p
      k - Number of hash functions. If 0, this value is derived from m and n
      bytesSupplier - a Function that convert objects of type E to byte[] arrays
      bitSet - BitSet holding this bloom filter's state. Caller must ensure that it has the correct size.
      Throws:
      IllegalArgumentException - if n or p is 0 or p is not between 0 and 1
      NullPointerException - if bytesSupplier is null
    • CountingBloomFilter

      public CountingBloomFilter(int n, double p, int m, int k, Function<E,byte[]> bytesSupplier)
      Create a new counting bloom filter with Short.BYTES * 8 bits reserved for the counters. Make sure to leave one parameter 0 as it must be derived from the other parameters.

      Visit Bloom Filter Calculator to get more information about the implications/calculation of these parameters.

      Parameters:
      n - Number of items in the filter
      p - Probability of false positives, fraction between 0 and 1
      m - Number of bits in the filter. If 0, this value is derived from n and p
      k - Number of hash functions. If 0, this value is derived from m and n
      bytesSupplier - a Function that convert objects of type E to byte[] arrays
      Throws:
      IllegalArgumentException - if n or p is 0 or p is not between 0 and 1
      NullPointerException - if bytesSupplier is null
    • CountingBloomFilter

      public CountingBloomFilter(int n, double p, Function<E,byte[]> bytesSupplier, int countingBits)
      Create a new counting bloom filter. Make sure to leave one parameter 0 as it must be derived from the other parameters.

      Visit Bloom Filter Calculator to get more information about the implications/calculation of these parameters.

      Parameters:
      n - Number of items in the filter
      p - Probability of false positives, fraction between 0 and 1
      bytesSupplier - a Function that convert objects of type E to byte[] arrays
      countingBits - number to bits used for the counter
      Throws:
      IllegalArgumentException - if n or p is 0 or p is not between 0 and 1
      NullPointerException - if bytesSupplier is null
    • CountingBloomFilter

      public CountingBloomFilter(int n, double p, Function<E,byte[]> bytesSupplier)
      Create a new counting bloom filter with Short.BYTES * 8 bits reserved for the counters. Make sure to leave one parameter 0 as it must be derived from the other parameters.

      Visit Bloom Filter Calculator to get more information about the implications/calculation of these parameters.

      Parameters:
      n - Number of items in the filter
      p - Probability of false positives, fraction between 0 and 1
      bytesSupplier - a Function that convert objects of type E to byte[] arrays
      Throws:
      IllegalArgumentException - if n or p is 0 or p is not between 0 and 1
      NullPointerException - if bytesSupplier is null
    • CountingBloomFilter

      public CountingBloomFilter(int n, double p, Function<E,byte[]> bytesSupplier, BitSet bitSet)
      Create a new counting bloom filter with Short.BYTES * 8 bits reserved for the counters. Make sure to leave one parameter 0 as it must be derived from the other parameters.

      Visit Bloom Filter Calculator to get more information about the implications/calculation of these parameters.

      Parameters:
      n - Number of items in the filter
      p - Probability of false positives, fraction between 0 and 1
      bytesSupplier - a Function that convert objects of type E to byte[] arrays
      bitSet - BitSet holding this bloom filter's state. Caller must ensure that it has the correct size.
      Throws:
      IllegalArgumentException - if n or p is 0 or p is not between 0 and 1
      NullPointerException - if bytesSupplier is null
  • Method Details