/**
 * A simple implementation of hash tables.
 */
public class HashTable
  implements GDictionary
{
  // +--------+------------------------------------------------------------
  // | Fields |
  // +--------+

  /**
   * The contents of the hash table.
   */
  public Pair[] contents;

  // +--------------+------------------------------------------------------
  // | Constructors |
  // +--------------+

  public HashTable() {
    this.contents = new Pair[10];
  } // HashTable()

  // +---------+-----------------------------------------------------------
  // | Methods |
  // +---------+

  /**
   * Get the index of a string.
   */
  int index(String key) {
    return Math.abs(key.hashCode() % this.contents.length);
  }

  /**
   * Look up stuff by name.
   */
  public Object get(String key)
  {
    return this.contents[index(key)];
  } // get(String)

  /**
   * Add stuff by name.
   */
  public void add(String key, Object value)
    throws Exception
  {
    this.contents[index(key)] = new Pair(key, value);
  } // add(String, Object)

  /**
   * Replace something.  Return the old value.
   *
   * @exception Exception
   *   if there is not value with the designated index.
   */
  public Object replace(String key, Object newValue)
    throws Exception
  {
    throw new Exception("Unimplemented");
  } // add(String, Object)
 
  /**
   * Delete an entry (all entries?) with a particular index.
   */
  public void delete(String key) 
  {
    // Stub
  }
} // class HashTable


