Assume that a HashEntry is a struct that has a pointer to a list(head). Bucket of a HashTable has a pointer to Bucket Entries(array of entries) Bucket Entry struct has a key that is char*.
struct BucketEntry{
char* key;
//irrelevant data
};
struct Bucket{
BucketEntry* entries;
struct Bucket* next;
int counter; // counts how keys are in.
};
struct HashEntry{
struct Bucket* head;
};
A hash table is a pointer of type HashEntry* to an array of entries, and heads are initialized to NULL
struct HashEntry* table = malloc(buckets*sizeof(struct HashEntry));
for(i = 0; i < buckets; i++){
table[i].head = NULL;
}
After that, i create a bucket like this and i assign it in to the proper hash ceil:
struct Bucket* bucket = malloc(sizeof( struct Bucket));
table[hash].head = bucket;
What is the proper way to allocate an array of Bucket Entries of quantum x? After the allocation , what is the proper way to assign it to the proper bucket&Hash ceil ?
Thank you and sorry for my english.