-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUniversalHashFunction.java
More file actions
27 lines (25 loc) · 986 Bytes
/
UniversalHashFunction.java
File metadata and controls
27 lines (25 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/***************************************************************************
* File: UniversalHashFunction.java
* Author: Keith Schwarz (htiek@cs.stanford.edu)
*
* An object representing a family of universal hash functions. The object
* can then hand back random instances of the universal hash function on an
* as-needed basis.
*/
public interface UniversalHashFunction<T> {
/**
* Given as input the number of buckets, produces a random hash function
* that hashes objects of type T into those buckets with the guarantee
* that
*<pre>
* Pr[h(x) == h(y)] <= |T| / numBuckets, forall x != y
*</pre>
* For all hash functions handed back.
*
* @param buckets The number of buckets into which elements should be
* partitioned.
* @return A random hash function whose distribution satisfies the above
* property.
*/
public HashFunction<T> randomHashFunction(int buckets);
}