|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.obsearch.index.bucket.SimpleBloomFilter<E>
E
- The type of object the BloomFilter should containpublic class SimpleBloomFilter<E>
A simple Bloom Filter (see http://en.wikipedia.org/wiki/Bloom_filter) that uses java.util.Random as a primitive hash function, and which implements Java's Set interface for convenience. Only the add(), addAll(), contains(), and containsAll() methods are implemented. Calling any other method will yield an UnsupportedOperationException. This code may be used, modified, and redistributed provided that the author tag below remains intact.
Field Summary | |
---|---|
protected int |
k
|
Constructor Summary | |
---|---|
SimpleBloomFilter(int bitArraySize,
int expectedElements)
Construct a SimpleBloomFilter. |
Method Summary | ||
---|---|---|
boolean |
add(E o)
|
|
boolean |
addAll(Collection<? extends E> c)
|
|
void |
clear()
Clear the Bloom Filter |
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
double |
expectedFalsePositiveProbability()
Calculates the approximate probability of the contains() method returning true for an object that had not previously been inserted into the bloom filter. |
|
boolean |
isEmpty()
Not implemented |
|
Iterator<E> |
iterator()
Not implemented |
|
boolean |
remove(Object o)
Not implemented |
|
boolean |
removeAll(Collection<?> c)
Not implemented |
|
boolean |
retainAll(Collection<?> c)
Not implemented |
|
int |
size()
Not implemented |
|
Object[] |
toArray()
Not implemented |
|
|
toArray(T[] a)
Not implemented |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
equals, hashCode |
Field Detail |
---|
protected int k
Constructor Detail |
---|
public SimpleBloomFilter(int bitArraySize, int expectedElements)
bitArraySize
- The number of bits in the bit array (often called 'm' in the
context of bloom filters).expectedElements
- The typical number of items you expect to be added to the
SimpleBloomFilter (often called 'n').Method Detail |
---|
public double expectedFalsePositiveProbability()
public boolean add(E o)
add
in interface Collection<E>
add
in interface Set<E>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in interface Set<E>
public void clear()
clear
in interface Collection<E>
clear
in interface Set<E>
public boolean contains(Object o)
contains
in interface Collection<E>
contains
in interface Set<E>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
containsAll
in interface Set<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in interface Set<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in interface Set<E>
public boolean remove(Object o)
remove
in interface Collection<E>
remove
in interface Set<E>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
removeAll
in interface Set<E>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E>
retainAll
in interface Set<E>
public int size()
size
in interface Collection<E>
size
in interface Set<E>
public Object[] toArray()
toArray
in interface Collection<E>
toArray
in interface Set<E>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<E>
toArray
in interface Set<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |