public class DoubleHashingHashTable extends OpenAddressingHashTable
1: //DoubleHashingHashTable.java (from zyDE 5.10.1)
3: public class DoubleHashingHashTable extends OpenAddressingHashTable
4: {
5: public DoubleHashingHashTable(int initialCapacity)
6: {
7: super(initialCapacity);
8: }
10: public DoubleHashingHashTable()
11: {
12: // Initialize with an initial capacity of 11
13: this(11);
14: }
16: // The secondary hash function. Many different functions can
17: // be used here. The function used here is a common one, with
18: // different (usually prime number) constants used where the 7 is.
19: private int h2(Object key)
20: {
21: return 7 - hash(key) % 7;
22: }
24: // Returns the bucket index for the specified key and i value using the
25: // double hashing probing sequence.
26: @Override
27: protected int probe(Object key, int i)
28: {
29: return (hash(key) + i * h2(key)) % table.length;
30: }
31: }