java.lang.Object
test.BloomFilter
-
Constructor Summary
ConstructorsConstructorDescriptionBloomFilter(int size, String... algo) The BloomFilter function takes in a string and hashes it using the hash functions that were passed into the constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidThe add function takes a string and hashes it using the hash functions in this.algo, then sets the corresponding bits in this.b to true.booleanThe contains function checks if the given word is in the BloomFilter.toString()The toString function returns a string representation of the BitVector.
-
Constructor Details
-
BloomFilter
The BloomFilter function takes in a string and hashes it using the hash functions that were passed into the constructor. It then sets those bits to 1.- Parameters:
size- int -Set the size of the bitsetalgo- A String array -Pass a variable number of arguments to the function
-
-
Method Details
-
add
The add function takes a string and hashes it using the hash functions in this.algo, then sets the corresponding bits in this.b to true.- Parameters:
word- String -Get the bytes of the word and then to hash it
-
contains
The contains function checks if the given word is in the BloomFilter.- Parameters:
word- String -Get the bytes of the word and then convert it to a biginteger- Returns:
- True if the word is in the filter and false otherwise
-
toString
The toString function returns a string representation of the BitVector.
-