Wednesday, July 10, 2013

Hash map implementation in C

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:

If you've Scripd account, download it here:
https://www.scribd.com/doc/247124214/Hash-Map-Lib


Migrating PDC data from one system to another

Given System “A” with BRM and PDC and System “B” with BRM and PDC, following is the process for moving new or changed pricing data from ...