Class CountingBloomFilter<E>
- Type Parameters:
E- the type of elements maintained by this set
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
BloomFilter that allows you to remove elements.-
Nested Class Summary
Nested classes/interfaces inherited from class org.drasyl.util.BloomFilter
BloomFilter.Parameters -
Field Summary
Fields inherited from class org.drasyl.util.BloomFilter
bitSet, bytesSupplier, parameters -
Constructor Summary
ConstructorsModifierConstructorDescriptionCountingBloomFilter(int n, double p, int m, int k, Function<E, byte[]> bytesSupplier) Create a new counting bloom filter withShort.BYTES * 8bits reserved for the counters.CountingBloomFilter(int n, double p, int m, int k, Function<E, byte[]> bytesSupplier, int countingBits) Create a new bloom filter.CountingBloomFilter(int n, double p, int m, int k, Function<E, byte[]> bytesSupplier, BitSet bitSet) Create a new counting bloom filter withShort.BYTES * 8bits reserved for the counters.CountingBloomFilter(int n, double p, int m, int k, Function<E, byte[]> bytesSupplier, BitSet bitSet, int countingBits) Create a new bloom filter.CountingBloomFilter(int n, double p, Function<E, byte[]> bytesSupplier) Create a new counting bloom filter withShort.BYTES * 8bits reserved for the counters.CountingBloomFilter(int n, double p, Function<E, byte[]> bytesSupplier, int countingBits) Create a new counting bloom filter.CountingBloomFilter(int n, double p, Function<E, byte[]> bytesSupplier, BitSet bitSet) Create a new counting bloom filter withShort.BYTES * 8bits reserved for the counters.protectedCountingBloomFilter(BloomFilter.Parameters parameters, Function<E, byte[]> bytesSupplier, int countingBits) protectedCountingBloomFilter(BloomFilter.Parameters parameters, Function<E, byte[]> bytesSupplier, BitSet bitSet, int countingBits) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleangetBit(int index) voidmerge(BloomFilter<E> other) Merges this filter withother.booleanNot supported.booleanremoveAll(Collection<?> c) Not supported.protected booleansetBit(int index) toString()protected booleanunsetBit(int index) Methods inherited from class org.drasyl.util.BloomFilter
add, addAll, bitset, clear, contains, containsAll, hashes, isEmpty, iterator, k, m, n, p, retainAll, size, toArray, toArrayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
equals, hashCode, spliterator
-
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 parameter0as it must be derived from the other parameters.Visit Bloom Filter Calculator to get more information about the implications/calculation of these parameters.
If
mis 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. If0, this value is derived fromp,m, andkp- Probability of false positives, fraction between 0 and 1. If0, this value is derived fromn,m, andkm- Number of bits in the filter. If0, this value is derived fromnandpk- Number of hash functions. If0, this value is derived frommandnbytesSupplier- aFunctionthat convert objects of typeEtobyte[]arraysbitSet-BitSetholding 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 not0orpis not between 0 and 1NullPointerException- ifbytesSupplierisnull
-
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 parameter0as it must be derived from the other parameters.Visit Bloom Filter Calculator to get more information about the implications/calculation of these parameters.
If
mis 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. If0, this value is derived fromp,m, andkp- Probability of false positives, fraction between 0 and 1. If0, this value is derived fromn,m, andkm- Number of bits in the filter. If0, this value is derived fromnandpk- Number of hash functions. If0, this value is derived frommandnbytesSupplier- aFunctionthat convert objects of typeEtobyte[]arrayscountingBits- number to bits used for the counter- Throws:
IllegalArgumentException- if one parameter is not0orpis not between 0 and 1NullPointerException- ifbytesSupplierisnull
-
CountingBloomFilter
public CountingBloomFilter(int n, double p, int m, int k, Function<E, byte[]> bytesSupplier, BitSet bitSet) Create a new counting bloom filter withShort.BYTES * 8bits reserved for the counters. Make sure to leave one parameter0as 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 filterp- Probability of false positives, fraction between 0 and 1m- Number of bits in the filter. If0, this value is derived fromnandpk- Number of hash functions. If0, this value is derived frommandnbytesSupplier- aFunctionthat convert objects of typeEtobyte[]arraysbitSet-BitSetholding this bloom filter's state. Caller must ensure that it has the correct size.- Throws:
IllegalArgumentException- ifnorpis0orpis not between 0 and 1NullPointerException- ifbytesSupplierisnull
-
CountingBloomFilter
Create a new counting bloom filter withShort.BYTES * 8bits reserved for the counters. Make sure to leave one parameter0as 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 filterp- Probability of false positives, fraction between 0 and 1m- Number of bits in the filter. If0, this value is derived fromnandpk- Number of hash functions. If0, this value is derived frommandnbytesSupplier- aFunctionthat convert objects of typeEtobyte[]arrays- Throws:
IllegalArgumentException- ifnorpis0orpis not between 0 and 1NullPointerException- ifbytesSupplierisnull
-
CountingBloomFilter
Create a new counting bloom filter. Make sure to leave one parameter0as 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 filterp- Probability of false positives, fraction between 0 and 1bytesSupplier- aFunctionthat convert objects of typeEtobyte[]arrayscountingBits- number to bits used for the counter- Throws:
IllegalArgumentException- ifnorpis0orpis not between 0 and 1NullPointerException- ifbytesSupplierisnull
-
CountingBloomFilter
Create a new counting bloom filter withShort.BYTES * 8bits reserved for the counters. Make sure to leave one parameter0as 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 filterp- Probability of false positives, fraction between 0 and 1bytesSupplier- aFunctionthat convert objects of typeEtobyte[]arrays- Throws:
IllegalArgumentException- ifnorpis0orpis not between 0 and 1NullPointerException- ifbytesSupplierisnull
-
CountingBloomFilter
Create a new counting bloom filter withShort.BYTES * 8bits reserved for the counters. Make sure to leave one parameter0as 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 filterp- Probability of false positives, fraction between 0 and 1bytesSupplier- aFunctionthat convert objects of typeEtobyte[]arraysbitSet-BitSetholding this bloom filter's state. Caller must ensure that it has the correct size.- Throws:
IllegalArgumentException- ifnorpis0orpis not between 0 and 1NullPointerException- ifbytesSupplierisnull
-
-
Method Details
-
toString
- Overrides:
toStringin classBloomFilter<E>
-
remove
Description copied from class:BloomFilterNot supported. ThrowsUnsupportedOperationException.- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classBloomFilter<E>- Returns:
- throws
UnsupportedOperationException
-
removeAll
Description copied from class:BloomFilterNot supported. ThrowsUnsupportedOperationException.- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceSet<E>- Overrides:
removeAllin classBloomFilter<E>- Returns:
- throws
UnsupportedOperationException
-
merge
Description copied from class:BloomFilterMerges this filter withother. While this filter will be contain the merged result,otherwill be unchanged.- Overrides:
mergein classBloomFilter<E>- Parameters:
other- bloom filter to merge
-
getBit
protected boolean getBit(int index) - Overrides:
getBitin classBloomFilter<E>
-
setBit
protected boolean setBit(int index) - Overrides:
setBitin classBloomFilter<E>
-
unsetBit
protected boolean unsetBit(int index)
-