#include "htbl_list.h"
#include "htbl.h"

/* hash table of strings, with linked list buckets */

/*
struct hash_table {
  unsigned long int(*hash)(void *);
  htbl_list **buckets;
  unsigned int n_buckets;
};
typedef struct hash_table htbl;
*/

/* good_hash : void -> unsigned int
 * compute hash code for given string
 * - see description of exercise for algorithm 
 */
unsigned long int good_hash(unsigned long int key, unsigned int size)
{
  fprintf(stderr,"TODO [htbl]: good_hash\n");
  exit(1);
}

/* bad_hash : void -> unsigned int
 * implement this however you like, as long as it's bad 
 */
unsigned long int bad_hash(unsigned long int key, unsigned int size)
{
  fprintf(stderr,"TODO [htbl]: bad_hash\n");
  exit(1);
}

/* htbl_create : ((string -> unsigned long),int) -> htbl*
 * allocate space for a new hash table of given size
 * - all buckets must initially be the empty list 
 */
htbl *htbl_create(unsigned long int(*h)(unsigned long, unsigned int), 
		unsigned long int (*calc)(void *),
		int (*comp)(void *, void *), unsigned int sz)
{
  fprintf(stderr,"TODO [htbl]: htbl_new\n");
  exit(1);
}

/* htbl_num_entries : htbl* -> unsigned int
 * return the total number of entries in all buckets 
 */
unsigned int htbl_num_entries(htbl *t)
{
  fprintf(stderr,"TODO [htbl]: htbl_num_entries\n");
  exit(1);
}

/* htbl_load_factor : htbl* -> float
 * The load factor is the mean number of elements per bucket. 
 */
double htbl_load_factor(htbl *t)
{
  fprintf(stderr,"TODO [htbl]: htbl_load_factor\n");
  exit(1);
}

/* htbl_max_bucket : (htbl*, unsigned int*, int*) -> <void>
 * Return, via out parameters, the max number of items in any
 * bucket, and the index of that bucket.
 * - If there is more than one bucket with that number of
 *   items, you may return any of those bucket indexes.
 */
void htbl_max_bucket(htbl *t, unsigned int *m, unsigned int *i)
{
  fprintf(stderr,"TODO [htbl]: htbl_max_bucket\n");
  exit(1);
}

/* htbl_insert : (void*, htbl*, unsigned int*) -> int
 * add string s to hash table t 
 * - no special treatment for duplicates, just insert them again
 * - return, via out parameter n, the number of strings in s's bucket 
 *   after inserting s
 */
void htbl_insert(void *s, htbl *t, unsigned int *n)
{
  fprintf(stderr,"TODO [htbl]: htbl_ins\n");
  exit(1);
}

/* htbl_contains : (void*, htbl*) -> int
 * test membership of given string in given table 
 */
int htbl_contains(void *s, htbl *t)
{
  fprintf(stderr,"TODO [htbl]: htbl_contains\n");
  exit(1);
}

/* htbl_print : (FILE*, htbl*) -> <void>
 * Print a representation of the hash table to f.
 * make sure you follow the printing suggestions to match our output
 * 
 */
void htbl_print(FILE *f, htbl *t, void (*print)(FILE *, void *))
{
  // for each bucket with items in it
  //printf("%d: "); // the bucket index gets printed out here
  // this is followed by the set of items in this bucket, 
  // then print a new line before the next one
  fprintf(stderr,"TODO [htbl]: htbl_print\n");
  exit(1);
}

/* htbl_free : htbl* -> <void>
 * Be sure to free everything. Drawing a picture may help.
 */
void htbl_free(htbl *t)
{
  fprintf(stderr,"TODO [htbl]: htbl_free\n");
  exit(1);
}
