SWEN-250 – Personal Software Engineering
Hashmap Activity
Problem
This activity requires you to write a C function that
deletes a symbol / value pair from a hashmap. The prototype (signature) of the
function is
void drop( char *symbol )
The given code hashmap.c includes the following functions:
insert( ) - inserts a symbol / value pair into the hashmap using symbol as the key
hash( ) – uses the given symbol to perform a hash function which computes the index (bin) into the hash table
lookup( ) – returns the hash table bin entry (symbol / value) for a given symbol
dump( ) - print all the symbol / value pairs for the hash table
main( ) – edit this function to include any tests you created to verify your solution.
The following standard string functions are also used:
int strcmp( char *s1, char *s2 ) – compares two strings, returns zero if strings are equal
char *strdup ( char *s1 ) – returns an allocated block of memory containing a duplicate of string s1
NOTE: In writing drop(), it is your
responsibility to ensure that all the allocated memory resources/areas are no
longer needed in the hash map are properly released in the proper order.