Package dsa.lab05.solutions
Class HashFunction
java.lang.Object
dsa.lab05.solutions.HashFunction
A randomly-chosen hash function from a universal family.
-
Constructor Summary
ConstructorsConstructorDescriptionHashFunction
(int size) Construct a hash function, randomly choosing its parameters. -
Method Summary
-
Constructor Details
-
HashFunction
public HashFunction(int size) Construct a hash function, randomly choosing its parameters.- Parameters:
size
- the range of hashes thathash(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
Hash the given object to a non-negative int less thansize()
.- Parameters:
object
- an object- Returns:
- a hash of that object
-