public class QuadraticProbingHashTable extends OpenAddressingHashTable
1: //QuadraticProbingHashTable.java (from zyDE 5.10.1)
3: public class QuadraticProbingHashTable extends OpenAddressingHashTable
4: {
5: private int c1;
6: private int c2;
8: public QuadraticProbingHashTable(int c1, int c2, int initialCapacity)
9: {
10: super(initialCapacity);
11: this.c1 = c1;
12: this.c2 = c2;
13: }
15: public QuadraticProbingHashTable()
16: {
17: // Initialize with c1=1, c2=1, and initialCapacity=11
18: this(1, 1, 11);
19: }
21: // Returns the bucket index for the specified key and i value using the
22: // quadratic probing sequence.
23: @Override
24: protected int probe(Object key, int i)
25: {
26: return (hash(key) + c1 * i + c2 * i * i) % table.length;
27: }
28: }