|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.mg4j.util.IntBloomFilter
dsiutils
.
@Deprecated public class IntBloomFilter
A Bloom filter for integers.
Instances of this class represent a set of integers (with false positives) using a Bloom filter. Because of the way Bloom filters work, you cannot remove elements.
Bloom filters have an expected error rate, depending on the number of hash functions used, on the filter size and on the number of elements in the filter. This implementation uses a variable optimal number of hash functions, depending on the expected number of elements. More precisely, a Bloom filter for n integers with d hash functions will use ln 2 dn ≈ 1.44 dn bits; false positives will happen with probability 2-d.
Hash functions are generated at creation time using universal hashing. Each hash function uses two integers A and B, and the integer x is mapped to (Ax)⊕B before taking the remainder modulo the number of bits in the filter.
This class exports access methods that are very similar to those of Set
,
but it does not implement that interface, as too many non-optional methods
would be unimplementable (e.g., iterators).
Field Summary | |
---|---|
int |
d
Deprecated. The number of hash functions used by this filter. |
int |
m
Deprecated. The number of bits in this filter. |
Constructor Summary | |
---|---|
IntBloomFilter(int n,
int d)
Deprecated. Creates a new Bloom filter with given number of hash functions and expected number of elements. |
Method Summary | |
---|---|
void |
add(int x)
Deprecated. Adds an integer to the filter. |
boolean |
contains(int x)
Deprecated. Checks whether the given integer is in this filter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int m
public final int d
Constructor Detail |
---|
public IntBloomFilter(int n, int d)
n
- the expected number of elements.d
- the number of hash functions; if the filter add not more than n
elements,
false positives will happen with probability 2-d.Method Detail |
---|
public boolean contains(int x)
Note that this method may return true on an integer that has not been added to the filter. This will happen with probability 2-d, where d is the number of hash functions specified at creation time, if the number of the elements in the filter is less than n, the number of expected elements specified at creation time.
x
- an integer.
public void add(int x)
x
- an integer.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |