|
ePOST API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rice.p2p.util.BloomFilter
public class BloomFilter
Field Summary | |
---|---|
protected int |
length
The length of the set to use |
static int |
PARAMETER_LENGTH
The length of the random byte arrays which are generated |
protected int[] |
parameters
The parameters to the hash functions for this bloom filter |
protected java.util.BitSet |
set
The underlying bitset representation for this bloom filter |
Constructor Summary | |
---|---|
BloomFilter(int num,
int length)
Constructor which takes the number of hash functions to use and the length of the set to use. |
Method Summary | |
---|---|
void |
add(byte[] array)
Method which adds an element to this bloom filter. |
boolean |
check(byte[] array)
Method which returns whether or not an element *may* be in the set. |
protected int |
doHash(byte[] array,
int seed)
Method which performs a dumb hash of the provided array and the seed value. |
java.lang.String |
getBitSet()
Method which returns what the internal bit set looks like as a string |
protected int |
hash(byte[] array,
int i)
Internal method which hashes the input argument using the ith hash function, and then mods the result by length. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int PARAMETER_LENGTH
protected int[] parameters
protected int length
protected java.util.BitSet set
Constructor Detail |
---|
public BloomFilter(int num, int length)
num
- The number of hash functions to uselength
- The length of the underlying bit setMethod Detail |
---|
public void add(byte[] array)
array
- The element to addpublic boolean check(byte[] array)
array
- The element to check forprotected int hash(byte[] array, int i)
array
- The element to hashi
- The hash function to useprotected int doHash(byte[] array, int seed)
array
- The input array
public java.lang.String getBitSet()
|
ePOST API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |