Class HashFunction

java.lang.Object
dsa.lab05.solutions.HashFunction

public class HashFunction extends Object
A randomly-chosen hash function from a universal family.
  • Constructor Details

    • HashFunction

      public HashFunction(int size)
      Construct a hash function, randomly choosing its parameters.
      Parameters:
      size - the range of hashes that hash(Object) should return
  • Method Details

    • size

      public int size()
      Get the size of the range of hashes.
      Returns:
      the range of hashes that hash(Object) should return
    • hash

      public int hash(Object object)
      Hash the given object to a non-negative int less than size().
      Parameters:
      object - an object
      Returns:
      a hash of that object