#include "dictionary.h"
#include "libicl.h"
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
Functions | |
| DICTIONARY * | dict_new (int(*_compar)(void *, void *), void(*_keyfree)(void *)) |
| Create a new dictionary that uses _compar() to determine equivalence of keys and _keyfree() to free keys (called by the dict_remove functions). | |
| int | dict_expand_capacity (DICTIONARY *dict) |
| Expand dictionary capacity by one increment. | |
| void * | dict_get (DICTIONARY *d, void *key) |
| Uses compar() to compare keys and return the corresponding value. | |
| int | dict_get_nth (DICTIONARY *d, void **key, void **value, int n) |
| Return the nth key and value in the list in variables key and value. | |
| int | dict_index_for_key (DICTIONARY *d, void *key) |
| Return the index assocated with this key or -1 if it doesn't exist. | |
| void * | dict_put (DICTIONARY *d, void *key, void *value) |
| Add a key/value pair to a dictionary. | |
| void * | dict_put_nonunique (DICTIONARY *d, void *key, void *value) |
| Add a key/value pair to a dictionary. | |
| void * | dict_remove (DICTIONARY *d, void *key) |
| Remove the first occurance of a key and it's associated value. | |
| void * | dict_remove_specific (DICTIONARY *d, void *key, void *value) |
| Remove the entry specified by this key/value pair. | |
| void ** | dict_remove_all (DICTIONARY *d, void *key, int *num_removed) |
| Remove all occurances of a key and it's associated values. | |
| void | dict_free (DICTIONARY *d) |
| Free the dictionary but not the contents. | |
Definition in file dictionary.c.
| int dict_expand_capacity | ( | DICTIONARY * | dict | ) |
Expand dictionary capacity by one increment.
Returns size of new dictionary.
Definition at line 63 of file dictionary.c.
| void dict_free | ( | DICTIONARY * | d | ) |
| void* dict_get | ( | DICTIONARY * | d, | |
| void * | key | |||
| ) |
Uses compar() to compare keys and return the corresponding value.
Definition at line 87 of file dictionary.c.
| int dict_get_nth | ( | DICTIONARY * | d, | |
| void ** | key, | |||
| void ** | value, | |||
| int | n | |||
| ) |
Return the nth key and value in the list in variables key and value.
Return 1 if there is a value and 0 if not.
Definition at line 102 of file dictionary.c.
| int dict_index_for_key | ( | DICTIONARY * | d, | |
| void * | key | |||
| ) |
Return the index assocated with this key or -1 if it doesn't exist.
Definition at line 114 of file dictionary.c.
| DICTIONARY* dict_new | ( | int(*)(void *, void *) | _compar, | |
| void(*)(void *) | _keyfree | |||
| ) |
Create a new dictionary that uses _compar() to determine equivalence of keys and _keyfree() to free keys (called by the dict_remove functions).
Definition at line 43 of file dictionary.c.
| void* dict_put | ( | DICTIONARY * | d, | |
| void * | key, | |||
| void * | value | |||
| ) |
Add a key/value pair to a dictionary.
If the key already exists, the value is replaced with this one and the old value is returned
Definition at line 129 of file dictionary.c.
| void* dict_put_nonunique | ( | DICTIONARY * | d, | |
| void * | key, | |||
| void * | value | |||
| ) |
Add a key/value pair to a dictionary.
With this function, the dictionary acts more like a vector in that it may add more than one value with the same key to the table. Returns the new value
Definition at line 157 of file dictionary.c.
| void* dict_remove | ( | DICTIONARY * | d, | |
| void * | key | |||
| ) |
Remove the first occurance of a key and it's associated value.
Call d->keyfree() to free the key. Return the associated value.
Definition at line 178 of file dictionary.c.
| void** dict_remove_all | ( | DICTIONARY * | d, | |
| void * | key, | |||
| int * | num_removed | |||
| ) |
Remove all occurances of a key and it's associated values.
Return the number of key/value pairs removed. Allocate an array (values) and set it to contain the values removed.
NOTE: "values" must be freed by the caller!
Definition at line 247 of file dictionary.c.
| void* dict_remove_specific | ( | DICTIONARY * | d, | |
| void * | key, | |||
| void * | value | |||
| ) |
Remove the entry specified by this key/value pair.
Call d->keyfree() to free the key. Return the associated value.
Warning -- this function assumes that the same comparison function is used for both keys and values. this will be true when they are both ICL_Terms.
Definition at line 210 of file dictionary.c.