diff --git a/PA10-1115/HashUtility.c b/PA10-1115/HashUtility.c index 1015d8b..73df61d 100644 --- a/PA10-1115/HashUtility.c +++ b/PA10-1115/HashUtility.c @@ -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. } \ No newline at end of file diff --git a/PA10-1115/PA10_Main b/PA10-1115/PA10_Main new file mode 100755 index 0000000..15ed720 Binary files /dev/null and b/PA10-1115/PA10_Main differ