typedef struct HashTabRep {
Item *items;
int nslots;
int nitems;
int nhash2;
} HashTabRep;
#define hash2(k,N2) (((k)%N2)+1)
HashTable newHashTable(int N)
{
HashTabRep *new = malloc(sizeof(HashTabRep));
assert(new != NULL);
new->items = malloc(N*sizeof(Item));
assert(new->items != NULL);
for (int i = 0; i < N; i++)
new->items[i] = NoItem;
new->nslots = N; new->nitems = 0;
new->nhash2 = findSuitablePrime(N);
return new;
}
|