DataStructures
Class QuadraticProbingTable<K,V>

java.lang.Object
  extended by DataStructures.ProbingHashTable<K,V>
      extended by DataStructures.QuadraticProbingTable<K,V>
Type Parameters:
K - the type of objects serving as keys
V - the type of objects serving as values
All Implemented Interfaces:
LookupTable<K,V>, java.lang.Iterable<LookupTable.Entry<K,V>>

public class QuadraticProbingTable<K,V>
extends ProbingHashTable<K,V>

A probing hash table implementation of a LookupTable with collisions resolved by quadratic probing.

Tables may be constructed, for example, by

      LookupTable<String,Integer> t = new QuadraticProbingTable<String,Integer>();
      t.add("one", 1);
      t.add("two", 2);
      t.add("three", 3);
 

To retrieve a value use for example:

      try {
        System.out.println(t.lookup("two"));
      } catch (NoSuchElementException e) {
        System.err.println(e);
      }
 

Entries can be read in sequence as follows:

      for (LookupTable.Entry<String,Integer> entry : t) {
          System.out.println(entry);
      }

Author:
Peter Williams
See Also:
LookupTable, ProbingHashTable

Constructor Summary
QuadraticProbingTable()
          Constructs a hash table with default initial size and load factor.
QuadraticProbingTable(int size)
          Constructs a hash table with specified initial size and default load factor.
QuadraticProbingTable(int size, double loadFactor)
          Constructs a hash table initially capable of holding the given number of entries subject to the give loadfactor.
 
Method Summary
 
Methods inherited from class DataStructures.ProbingHashTable
add, contains, isEmpty, iterator, lookup, remove, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuadraticProbingTable

public QuadraticProbingTable(int size,
                             double loadFactor)
Constructs a hash table initially capable of holding the given number of entries subject to the give loadfactor. The table will grow if necessary to ensure the load factor is not exceeded. The specified load factor must lie between 0 and 0.5.

Parameters:
size - the minimum number of entries to be made initially
loadFactor - the maximum loading before the table must grow
Throws:
java.lang.IllegalArgumentException - if the specified load factor is out of range

QuadraticProbingTable

public QuadraticProbingTable(int size)
Constructs a hash table with specified initial size and default load factor.

Parameters:
size - the minimum number of entries to be made initially

QuadraticProbingTable

public QuadraticProbingTable()
Constructs a hash table with default initial size and load factor.