/*
 * a simple hash table to store variable names
 */

typedef struct {
  int lf;         /* load factor (actually the inverse, eg 0.1 = 10) */
  int capacity;   /* maximum number of entries */
  int count;      /* number of current entries */
  void **table;   /* table of pointers */
  unsigned int (*hash)(const void *); /* hash function */
  int (*cmp)(const void *, const void *); /* comparator */
} hash_table_t;


/*
 * calculates base raised to the exponent
 */
unsigned int powi (unsigned int base, unsigned int power);

/*
 * calclulates a hash code for a string
 */
unsigned int str_hash_code (const void *ptr);

/*
 * initializes the hash table to a given capacity, load factor, with the
 * given comparator and hash functions
 */
void hash_init (hash_table_t *ht, int capacity, int lf,
		unsigned int (*hash)(const void *),
		int (*cmp)(const void *, const void *));

/*
 * inserts a value into the hash table, possibly rehashing it to grow it
 */
void hash_insert (hash_table_t *ht, void *ptr);

/*
 * tests if a value is present in the hash table
 */
int hash_test (hash_table_t *ht, void *ptr);

