|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.tomp2p.rpc.CountingBloomFilter<E>
E
- The type of object the BloomFilter should containpublic class CountingBloomFilter<E>
A counting 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.
Constructor Summary | |
---|---|
CountingBloomFilter(int expectedElements,
int[] intSet)
Constructs a CountingBloomFilter out of existing data. |
Method Summary | ||
---|---|---|
boolean |
add(E o)
|
|
boolean |
addAll(Collection<? extends E> c)
|
|
int |
approximateCount(E key)
Returns the number of times that an element has been added. |
|
void |
clear()
Clear the Bloom Filter |
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
boolean |
equals(Object obj)
|
|
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. |
|
int |
getExpectedElements()
Returns the expected elements that was provided by the user. |
|
int[] |
getIntSet()
Returns the bitset that backs the bloom filter |
|
int |
hashCode()
|
|
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 |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CountingBloomFilter(int expectedElements, int[] intSet)
expectedElements
- he typical number of items you expect to be added to the CountingBloomFilter (often
called 'n').intSet
- The data that will be used in the backing BitSetMethod Detail |
---|
public double expectedFalsePositiveProbability()
public int getExpectedElements()
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>
c
- The collection to add
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>
o
- The object to compare
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
containsAll
in interface Set<E>
c
- The collection to check if its inside this bloom filter
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>
public int[] getIntSet()
public int approximateCount(E key)
key
- The key to count
public boolean equals(Object obj)
equals
in interface Collection<E>
equals
in interface Set<E>
equals
in class Object
public int hashCode()
hashCode
in interface Collection<E>
hashCode
in interface Set<E>
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |