Initialize PA10, STUB Functions

++ PA10 Files
++ Makefile for PA10
This commit is contained in:
Charles Descamps 2023-11-10 14:34:28 -07:00
parent d9e90f6501
commit 91ce50b189
17 changed files with 4154 additions and 0 deletions

209
PA10-1115/HashUtility.c Normal file
View file

@ -0,0 +1,209 @@
// header files
#include "HashUtility.h"
// constants
/*
typedef struct HashStruct
{
StateDataType *array;
int tableSize;
ProbeType probeStrategy;
} ProbingHashType;
*/
// function definitions
/*
Name: addItemFromData
Process: adds item to hash table using data input,
sets node to used state
Function input/parameters: hash data (ProbingHashType *),
state name (const char *),
average, lowest, and highest temperatures (double),
Function output/parameters: updated hash table data (ProbingHashType *)
Function output/returned: result of operation (bool)
Device input/---: none
Device output/monitor: probing process displayed (in called function)
Dependencies: setDataNodeFromData, addItemFromStruct
*/
bool addItemFromData( ProbingHashType *hashTable, const char *stateName,
double avgTemp, double lowTemp, double highTemp )
{
// return false (temp)
return false;
}
/*
Name: addItemFromStruct
Process: adds item to hash table using struct input,
uses probing as specified in hashTable data,
either LINEAR_PROBING or QUADRATIC_PROBING,
may probe as many as tableSize times
Function input/parameters: hash data (ProbingHashType *),
new item (StateDataType)
Function output/parameters: updated hash table data (ProbingHashType *)
Function output/returned: result of operation (bool)
Device input/---: none
Device output/monitor: probing process displayed
Dependencies: getHashIndex, privateToPower, printf, stateDataToString,
setDataNodeFromStruct
*/
bool addItemFromStruct( ProbingHashType *hashTable, StateDataType newItem )
{
// return false (temp)
return false;
}
/*
Name: clearHashTable
Process: clear hash table array, deallocates hash struct
Function input/parameters: hash data (ProbingHashType *)
Function output/parameters: updated hash table data (ProbingHashType *)
Function output/returned: none
Device input/---: none
Device output/---: none
Dependencies: free
*/
void clearHashTable( ProbingHashType *hashTable )
{
// no return, void.
}
/*
Name: displayHashTable
Process: array data dump of numbered data to screen,
shows data where used, shows "Unused" where not
Function input/parameters: provided hashTable data (const ProbingHashType *)
Function output/parameters: none
Function output/returned: none
Device input/---: none
Device output/monitor: displayed as specified
Dependencies: printf, stateDataToString
*/
void displayHashTable( const ProbingHashType *hashTable )
{
// no return, void.
}
/*
Name: findItem
Process: finds item in hash table, returns
Function input/parameters: provided search data (const StateDataType),
hashTable (const ProbingHashType *)
Function output/parameters: none
Function output/returned: state data set to struct (StateDataType),
or search parameter set to empty node if not found
Device input/---: none
Device output/---: none
Dependencies: findItemIndex, setEmptyDataNode
*/
StateDataType findItem( const ProbingHashType *hashTable,
StateDataType searchItem )
{
// return NULL (temp)
return;
}
/*
Name: findItemIndex
Process: finds item index, using probing strategy provided in hashTable data,
otherwise,
returns ITEM_NOT_FOUND if search fails after tableSize attempts,
displays index probing attempts
Function input/parameters: provided search data (const StateDataType),
hashTable (const ProbingHashType *)
Function output/parameters: none
Function output/returned: index or ITEM_NOT_FOUND (int) as specified
Device input/---: none
Device output/monitor: displays probing action, provided in sample run file
Dependencies: getHashIndex, printf, privateCompareStrings, privateToPower,
setDataNodeFromStruct
*/
int findItemIndex( const ProbingHashType *hashTable, StateDataType searchItem )
{
// return zero (temp)
return 0;
}
/*
Name: getHashIndex
Process: finds hashed index for given data item,
sums integer values of state name characters,
if state name length is less than MINIMUM_HASH_LETTER_COUNT,
repeats going over the state letters as needed to meet this minimum
Function input/parameters: provided search data (const StateDataType),
hashTable (const ProbingHashType)
Function output/parameters: none
Function output/returned: array index generated from state name (int)
Device input/---: none
Device output/---: none
Dependencies: privateGetStringLength
*/
int getHashIndex( const ProbingHashType hashTable, const StateDataType state )
{
// return zero (temp)
return 0;
}
/*
Name: initializeHashTable
Process: creates dynamically allocated hashTable,
creates dynamically allocated array of empty StateDataType items,
initializes tableSize to given capacity,
initializes probe strategy to given strategy
Function input/parameters: provided capacity (int),
provided probe strategy (ProbeType)
Function output/parameters: none
Function output/returned: pointer to created hashTable (ProbingHashType *)
Device input/---: none
Device output/---: none
Dependencies: malloc, setEmptyDataNode,
*/
ProbingHashType *initializeHashTable( int capacity, ProbeType probe )
{
// return NULL (temp)
return NULL;
}
/*
Name: removeState
Process: finds item in hash table, removes,
sets array location to unused (but does not set any other data),
returns removed state
Function input/parameters: provided search data (const StateDataType),
hashTable (const ProbingHashType)
Function output/parameters: returned state (StateDataType *)
Function output/returned: Boolean result of action (bool)
Device input/---: none
Device output/---: none
Dependencies: findItemIndex, setDataNodeFromStruct
*/
bool removeState( StateDataType *removedState,
const StateDataType toBeRemoved, const ProbingHashType hashTable )
{
// return false (temp)
return false;
}
/*
Name: showHashTableStatus
Process: displays array <D>ata values and <U>unused values
as a string of letters,
displays number of items in hashTable,
displays minimum number of contiguous data items,
displays maximum number of contiguous data items,
displays number of empty/unused array elements
Function input/parameters: hashTable (const ProbingHashType)
Function output/parameters: none
Function output/returned: none
Device input/---: none
Device output/monitor: hash data status displayed as specified
Dependencies: sprintf, printf
*/
void showHashTableStatus( const ProbingHashType hashTable)
{
// no return, void.
}