#ifndef HASH_H
#define HASH_H
/* Adam Kaplan
 * kaplan@cs.ucla.edu
 * January 30, 2003
 * Hashtable of unsigned integer-to-unsigned integer mappings 
 */
#define INITSIZE 50

#include "bucketlist.h"

/* a hashtable that maps an integer to another integer */
struct s_hashtable {
	int size;	/* size of buckets list */
	int numEntries;	/* number of table entries */
	bucketlist * buckets;
};
typedef struct s_hashtable hashtable;

/* initializes hashtable h to have INITSIZE buckets */
void hash_init(hashtable *h);

/* insert the association (key, value) into hashtable h */
void hash_insert(hashtable *h, int key, int val);

/* hash function for a given key in a pair _returns insertion bucket */
int hash (int key, int numBuckets);

/* fetch an associated rightmost pair value from a hashtable given key
 * return -1 on failure
 * (Assumes you cannot have a value of -1)
 */
int hash_fetch(hashtable *h, int key);

/* finds and deletes a value from the buckets of a hashtable given its
 * lookup key...
 * returns 1 if operation successful, 0 otherwise 
 */
int hash_deleteEntry(hashtable *h, int key);

/* copies buckets into a new set of buckets by rehashing them
 * shouldn't be called often... (doubles size of hashtable h)
 */
void hash_resize(hashtable *h);

#endif
