Text Analytics Library
a collection of routines for simple textual analysis
 All Files Functions Typedefs
Typedefs | Enumerations | Functions
word_map.h File Reference

data structure and associated functions to work with lists of words, integer pairs More...

Go to the source code of this file.

Typedefs

typedef struct word_map * word_map_t
 
typedef struct word_map_node * word_node_t
 

Enumerations

enum  { AMAP_SORT_DESCENDING =0x00, AMAP_SORT_ASCENDING =0x01 }
 

Functions

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...
 

Detailed Description

data structure and associated functions to work with lists of words, integer pairs

Function Documentation

word_map_t word_map_create ( size_t  n)
Parameters
ninitial size of word_map
word_node_t word_map_find ( const word_map_t  wm,
const char *  word 
)
Parameters
wmpointer to word map structure
word,wordto 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
wmthe word map
fcntpointer 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
aninitialized 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
wmthe word map
fcntpointer to function that is called for each item in wm
nnumber of items in wordmap to apply fnct to