/* hash.h
 *
 * Originally borrowed from Dan's implementation of Collins' Model 1. 
 *
 * $Id: hash.h,v 1.2 2007/06/05 20:20:51 post Exp $
 */

#ifndef HASH_H
#define HASH_H

#include <cstring>

using namespace std;

class HashTable {
 public:
  char *entry(const char *str); // returns pointer to same string -
  // adds to table if not already present
  HashTable(int s = 23);
  ~HashTable();

 private:
  class Link {
  public:
    Link(const char *str, Link* n = NULL);
    ~Link();
    char *s;
    Link *next;
  };

  Link **buckets;
  int sizeOfTable, count; /* num of buckets, num of strings in table */
  void rehash();         /* double num of buckets */
  int hash(const char *s);     /* return hash value mod sizeOfTable */
};

char* StringTableEntry(const char*);

#endif
