Package test

Class BloomFilter

java.lang.Object
test.BloomFilter

public class BloomFilter extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    BloomFilter(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 Type
    Method
    Description
    void
    add(String word)
    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.
    boolean
    The contains function checks if the given word is in the BloomFilter.
    The toString function returns a string representation of the BitVector.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BloomFilter

      public BloomFilter(int size, String... algo)
      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 bitset
      algo - A String array -Pass a variable number of arguments to the function
  • Method Details

    • add

      public void add(String word)
      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

      public boolean contains(String word)
      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

      public String toString()
      The toString function returns a string representation of the BitVector.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the bitset