Nightly Data Dump
+- HashUtility.c ++ PA10_Main
This commit is contained in:
parent
c1e9dd47db
commit
6911280eb5
2 changed files with 55 additions and 0 deletions
|
|
@ -91,6 +91,25 @@ Dependencies: printf, stateDataToString
|
|||
*/
|
||||
void displayHashTable( const ProbingHashType *hashTable )
|
||||
{
|
||||
int dispIterator;
|
||||
char dispState[MAX_STR_LEN];
|
||||
// print out the 'title card' for the display
|
||||
printf("\nHASH TABLE ARRAY DUMP:\n");
|
||||
// iterate through the array
|
||||
for(dispIterator = 0; dispIterator < hashTable->tableSize; dispIterator++)
|
||||
{
|
||||
if(hashTable->array[dispIterator].inUse)
|
||||
{
|
||||
// print the state data using stateDataToString
|
||||
stateDataToString(dispState, hashTable->array[dispIterator]);
|
||||
printf("%2d) %s\n", dispIterator + 1, dispState);
|
||||
}
|
||||
else
|
||||
{
|
||||
// print "Unused" in the table
|
||||
printf("%2d) Unused\n", dispIterator + 1);
|
||||
}
|
||||
}
|
||||
// no return, void.
|
||||
}
|
||||
|
||||
|
|
@ -228,5 +247,41 @@ Dependencies: sprintf, printf
|
|||
*/
|
||||
void showHashTableStatus( const ProbingHashType hashTable)
|
||||
{
|
||||
int itemCount = 0, statusIterator, contigCount, maxContig, minContig;
|
||||
// display the hash table status, then iterate through either used/unused
|
||||
printf("\nHash Table Status: ");
|
||||
for(statusIterator = 0; statusIterator < hashTable.tableSize; statusIterator++)
|
||||
{
|
||||
contigCount = 1;
|
||||
// check to see if inUse
|
||||
if(hashTable.array[statusIterator].inUse)
|
||||
{
|
||||
// print 'D'
|
||||
printf("D");
|
||||
itemCount = itemCount + 1;
|
||||
contigCount = contigCount + 1;
|
||||
// check to see if the contigCount is bigger than old maxContig
|
||||
if (contigCount > maxContig)
|
||||
{
|
||||
maxContig = contigCount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// check to see if the contigCount is less than old minContig
|
||||
if(contigCount < minContig)
|
||||
{
|
||||
minContig = contigCount;
|
||||
}
|
||||
contigCount = 1;
|
||||
// print 'U'
|
||||
printf("U");
|
||||
}
|
||||
}
|
||||
printf("\nD => Data, U => Unused\n\n");
|
||||
printf(" Items in Hash Table: %d\n", itemCount);
|
||||
printf(" Minimum contiguous bins: %d\n", itemCount);
|
||||
printf(" Maximum contiguous bins: %d\n", itemCount);
|
||||
printf(" Number of empty bins: %d\n", itemCount);
|
||||
// no return, void.
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue