data structure and associated functions to work with lists of words, integer pairs
More...
Go to the source code of this file.
|
typedef struct word_map * | word_map_t |
|
typedef struct word_map_node * | word_node_t |
|
|
enum | { AMAP_SORT_DESCENDING =0x00,
AMAP_SORT_ASCENDING =0x01
} |
|
|
word_map_t | word_map_create (size_t n) |
|
void | word_map_free (word_map_t words) |
|
word_node_t | word_map_find (const word_map_t wm, const char *word) |
|
int | word_map_insert (word_map_t wm, const char *key, int val) |
|
void | word_map_sort (word_map_t wm, int(*compar)(const void *, const void *)) |
|
unsigned long | word_map_count (const word_map_t wm) |
|
void | word_count_inc (word_node_t node, int value) |
|
int | word_node_compare (const word_node_t n1, const word_node_t n2, int opt) |
|
void | word_map_foreach (const word_map_t wm, void(*fnct)(const char *, int)) |
| apply a function to each item in word map More...
|
|
void | word_map_nforeach (const word_map_t wm, void(*fnct)(const char *, int), int n) |
| apply a function to the first n word map items More...
|
|
data structure and associated functions to work with lists of words, integer pairs
word_map_t word_map_create |
( |
size_t |
n | ) |
|
- Parameters
-
n | initial size of word_map |
word_node_t word_map_find |
( |
const word_map_t |
wm, |
|
|
const char * |
word |
|
) |
| |
- Parameters
-
wm | pointer to word map structure |
word,word | to find |
- Returns
- a pointer to the node containing the entry for word or NULL if no matching entry is found.
void word_map_foreach |
( |
const word_map_t |
wm, |
|
|
void(*)(const char *, int) |
fnct |
|
) |
| |
apply a function to each item in word map
- Parameters
-
wm | the word map |
fcnt | pointer to function that is called for each item in wm |
Note that this is a specialized case of word_map_nforeach where n happens to be the number of items in wm
void word_map_free |
( |
word_map_t |
words | ) |
|
- Parameters
-
an | initialized word_map object |
void word_map_nforeach |
( |
const word_map_t |
wm, |
|
|
void(*)(const char *, int) |
fnct, |
|
|
int |
n |
|
) |
| |
apply a function to the first n word map items
- Parameters
-
wm | the word map |
fcnt | pointer to function that is called for each item in wm |
n | number of items in wordmap to apply fnct to |