E
- the type of elements contained in the bloom filter.public interface BloomFilter<E>
BloomFilter<T> filter = ...; Set<T> expensiveSet = ...; // e.g. database, web-service if (filter.mightContain(element)) { // Perform the more expensive check to be sure return expensive.contains(element); } return false;Note: this assumes that the Bloom Filter is kept in-sync with the definitive set! How this is accomplished is outside of the scope of this package. All Bloom Filter implementations in this package allow the probability of false positives (FPP) to be specified, and the implementation will adjust the amount of memory used to ensure the given level of accuracy for the expected number of elements.
Modifier and Type | Method and Description |
---|---|
void |
add(E element)
Adds the specified element to this set if it is not already possibly present.
|
void |
addAll(Collection<? extends E> elements)
Adds all of the specified elements to this set if they are not possibly already present.
|
BloomFilterStatistics |
getStatistics()
Gets a snapshot of the current statistics of the set.
|
boolean |
mightContain(E element)
Checks if the given element might be a member of this set.
|
void add(E element)
mightContain(Object)
will return true
for the same object.element
- the element to add to this set.void addAll(Collection<? extends E> elements)
elements
- the elements to add to the set.boolean mightContain(E element)
false
, then
the given object is definitely not a member of the set. If the result is true
then the object may or
may not be a member of this set, with a certain probability of false positives.element
- the element to check for membership in this set.false
if the element is definitely not in the set, or true
if it might be.BloomFilterStatistics getStatistics()
Copyright © 2025 Open Identity Platform Community. All rights reserved.