Finished StateDataUtility, Started HashUtility

+- HashUtiltity.c
+- StateDataUtility.c
This commit is contained in:
Charles Descamps 2023-11-13 15:09:13 -07:00
parent 6969f405e3
commit c1e9dd47db
2 changed files with 30 additions and 3 deletions

View file

@ -71,6 +71,10 @@ Dependencies: free
*/
void clearHashTable( ProbingHashType *hashTable )
{
// free the internal array
free(hashTable->array);
// free the rest of the structure
free(hashTable);
// no return, void.
}
@ -166,8 +170,25 @@ Dependencies: malloc, setEmptyDataNode,
*/
ProbingHashType *initializeHashTable( int capacity, ProbeType probe )
{
// return NULL (temp)
return NULL;
int initIterator;
// use malloc to initialize the table
ProbingHashType *createdHashTable =
(ProbingHashType *) malloc(sizeof(ProbingHashType));
// use malloc to create the array
createdHashTable->array =
(StateDataType *) malloc(sizeof(StateDataType) * capacity);
// iterate through the entire array, set to empty data
for(initIterator = 0; initIterator < capacity; initIterator++)
{
// set the array's items to empty.
setEmptyDataNode(&createdHashTable->array[initIterator]);
}
// define the size of the table to capacity.
createdHashTable->tableSize = capacity;
// define the probing strategy given.
createdHashTable->probeStrategy = probe;
// return the created hash table
return createdHashTable;
}
/*