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
ModifierConstructorDescriptionCountingBloomFilter
(int n, double p, int m, int k, Function<E, byte[]> bytesSupplier) Create a new counting bloom filter withShort.BYTES * 8
bits 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 * 8
bits 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 * 8
bits 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 * 8
bits reserved for the counters.protected
CountingBloomFilter
(BloomFilter.Parameters parameters, Function<E, byte[]> bytesSupplier, int countingBits) protected
CountingBloomFilter
(BloomFilter.Parameters parameters, Function<E, byte[]> bytesSupplier, BitSet bitSet, int countingBits) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
getBit
(int index) void
merge
(BloomFilter<E> other) Merges this filter withother
.boolean
Not supported.boolean
removeAll
(Collection<?> c) Not supported.protected boolean
setBit
(int index) toString()
protected boolean
unsetBit
(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, toArray
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods 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 parameter0
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. If0
, this value is derived fromp
,m
, andk
p
- Probability of false positives, fraction between 0 and 1. If0
, this value is derived fromn
,m
, andk
m
- Number of bits in the filter. If0
, this value is derived fromn
andp
k
- Number of hash functions. If0
, this value is derived fromm
andn
bytesSupplier
- aFunction
that convert objects of typeE
tobyte[]
arraysbitSet
-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 not0
orp
is not between 0 and 1NullPointerException
- ifbytesSupplier
isnull
-
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 parameter0
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. If0
, this value is derived fromp
,m
, andk
p
- Probability of false positives, fraction between 0 and 1. If0
, this value is derived fromn
,m
, andk
m
- Number of bits in the filter. If0
, this value is derived fromn
andp
k
- Number of hash functions. If0
, this value is derived fromm
andn
bytesSupplier
- aFunction
that convert objects of typeE
tobyte[]
arrayscountingBits
- number to bits used for the counter- Throws:
IllegalArgumentException
- if one parameter is not0
orp
is not between 0 and 1NullPointerException
- ifbytesSupplier
isnull
-
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 * 8
bits reserved for the counters. Make sure to leave one parameter0
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 filterp
- Probability of false positives, fraction between 0 and 1m
- Number of bits in the filter. If0
, this value is derived fromn
andp
k
- Number of hash functions. If0
, this value is derived fromm
andn
bytesSupplier
- aFunction
that convert objects of typeE
tobyte[]
arraysbitSet
-BitSet
holding this bloom filter's state. Caller must ensure that it has the correct size.- Throws:
IllegalArgumentException
- ifn
orp
is0
orp
is not between 0 and 1NullPointerException
- ifbytesSupplier
isnull
-
CountingBloomFilter
Create a new counting bloom filter withShort.BYTES * 8
bits reserved for the counters. Make sure to leave one parameter0
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 filterp
- Probability of false positives, fraction between 0 and 1m
- Number of bits in the filter. If0
, this value is derived fromn
andp
k
- Number of hash functions. If0
, this value is derived fromm
andn
bytesSupplier
- aFunction
that convert objects of typeE
tobyte[]
arrays- Throws:
IllegalArgumentException
- ifn
orp
is0
orp
is not between 0 and 1NullPointerException
- ifbytesSupplier
isnull
-
CountingBloomFilter
Create a new counting bloom filter. Make sure to leave one parameter0
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 filterp
- Probability of false positives, fraction between 0 and 1bytesSupplier
- aFunction
that convert objects of typeE
tobyte[]
arrayscountingBits
- number to bits used for the counter- Throws:
IllegalArgumentException
- ifn
orp
is0
orp
is not between 0 and 1NullPointerException
- ifbytesSupplier
isnull
-
CountingBloomFilter
Create a new counting bloom filter withShort.BYTES * 8
bits reserved for the counters. Make sure to leave one parameter0
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 filterp
- Probability of false positives, fraction between 0 and 1bytesSupplier
- aFunction
that convert objects of typeE
tobyte[]
arrays- Throws:
IllegalArgumentException
- ifn
orp
is0
orp
is not between 0 and 1NullPointerException
- ifbytesSupplier
isnull
-
CountingBloomFilter
Create a new counting bloom filter withShort.BYTES * 8
bits reserved for the counters. Make sure to leave one parameter0
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 filterp
- Probability of false positives, fraction between 0 and 1bytesSupplier
- aFunction
that convert objects of typeE
tobyte[]
arraysbitSet
-BitSet
holding this bloom filter's state. Caller must ensure that it has the correct size.- Throws:
IllegalArgumentException
- ifn
orp
is0
orp
is not between 0 and 1NullPointerException
- ifbytesSupplier
isnull
-
-
Method Details
-
toString
- Overrides:
toString
in classBloomFilter<E>
-
remove
Description copied from class:BloomFilter
Not supported. ThrowsUnsupportedOperationException
.- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classBloomFilter<E>
- Returns:
- throws
UnsupportedOperationException
-
removeAll
Description copied from class:BloomFilter
Not supported. ThrowsUnsupportedOperationException
.- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceSet<E>
- Overrides:
removeAll
in classBloomFilter<E>
- Returns:
- throws
UnsupportedOperationException
-
merge
Description copied from class:BloomFilter
Merges this filter withother
. While this filter will be contain the merged result,other
will be unchanged.- Overrides:
merge
in classBloomFilter<E>
- Parameters:
other
- bloom filter to merge
-
getBit
protected boolean getBit(int index) - Overrides:
getBit
in classBloomFilter<E>
-
setBit
protected boolean setBit(int index) - Overrides:
setBit
in classBloomFilter<E>
-
unsetBit
protected boolean unsetBit(int index)
-