Class BloomFilter

java.lang.Object
Model.gameClasses.BloomFilter

public class BloomFilter extends Object
  • Field Details

    • bitSet

      public BitSet bitSet
    • hashFuncs

      public String[] hashFuncs
  • Constructor Details

    • BloomFilter

      public BloomFilter(int bits, String... algs)
      gets a string and hashes it using the hashFunctions that are passed in the constructor, then turn all these bits on to 1.
      Parameters:
      bits - the length of the bit vector
      algs - the name of the HashFunctions we will use
  • Method Details

    • add

      public void add(String word)
      put a given word in the bloom filter
      Parameters:
      word - the word we will put in the bloom filter
    • contains

      public boolean contains(String word)
      Check if a given word exists in the bloom filter
      Parameters:
      word - the word we will check if it exists in the bloom filter
      Returns:
      true if the word exists (may be false positive), false if the word doesn't exist.
    • toString

      public String toString()
      converts the bitset into a string
      Overrides:
      toString in class Object
      Returns:
      a string of the bitset vector