I've written a hash map in C which is based on linked list data structure. It may be useful in various scenarios. Here is the list of the APIs implemented in this:
// Hash map structure
struct hash_map_t{
struct hash_map_t* nxt;
char* account_poid; //Key
int status; // Value
}
=> HASH MAP OPERATIONS
/*
* Function to insert/update a key-value pair
* If the key doesn't exist, this function will create a new node and add the
* key-value pair, if the key already exit, its value will be updated
*/
void hash_map_set( struct hash_map_t* hm,
char* acc_poid,
int status);
/*
* Function to free the memory allocated by hash map
*/
void free_hash_map(struct hash_map_t* hm);
/*
* Function to retrieve the map node with the kep acc_poid
*/
struct hash_map_t* getNodeWithKey(
struct hash_map_t* hm,
char* acc_poid);
/*
* Function to retrieve the map node using value status
*/
struct hash_map_t* getNodeWithValue(
struct hash_map_t* hm,
int status);
The code is attached at the following location: