MP7 MapReduce
|
#include <search.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "libdictionary.h"
Functions | |
void | dictionary_init (dictionary_t *d) |
Must be called first, initializes the dictionary data structure. | |
int | dictionary_add (dictionary_t *d, const char *key, const char *value) |
Adds a (key, value) pair to the dictionary. | |
const char * | dictionary_get (dictionary_t *d, const char *key) |
int | dictionary_remove (dictionary_t *d, const char *key) |
Removes the (key, value) entry from the dictionary. | |
int | dictionary_remove_free (dictionary_t *d, const char *key) |
Removes the (key, value) entry from the dictionary. | |
void | dictionary_destroy (dictionary_t *d) |
Frees all internal memory associated with the dictionary. | |
void | dictionary_destroy_free (dictionary_t *d) |
Frees all internal memory associated with the dictionary AND makes a call to dictionary_remove_free() for each entry that still exists in the dictionary at the time dictionary_destroy_free() is called. |
int dictionary_add | ( | dictionary_t * | d, |
const char * | key, | ||
const char * | value | ||
) |
Adds a (key, value) pair to the dictionary.
void dictionary_destroy | ( | dictionary_t * | d | ) |
Frees all internal memory associated with the dictionary.
Must be called last.
void dictionary_destroy_free | ( | dictionary_t * | d | ) |
Frees all internal memory associated with the dictionary AND makes a call to dictionary_remove_free() for each entry that still exists in the dictionary at the time dictionary_destroy_free() is called.
Since this function makes use of dictionary_remove_free(), this function is unsafe if you have used non-heap memory when calling dictionary_add().
const char* dictionary_get | ( | dictionary_t * | d, |
const char * | key | ||
) |
void dictionary_init | ( | dictionary_t * | d | ) |
Must be called first, initializes the dictionary data structure.
Same as MP1.
int dictionary_remove | ( | dictionary_t * | d, |
const char * | key | ||
) |
Removes the (key, value) entry from the dictionary.
int dictionary_remove_free | ( | dictionary_t * | d, |
const char * | key | ||
) |
Removes the (key, value) entry from the dictionary.