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

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

Go to the source code of this file.

Typedefs

typedef struct word_list * word_list_t
 

Functions

word_list_t word_list_create (size_t n)
 create a new word list More...
 
void word_list_free (word_list_t words)
 free the memory associated with a word list More...
 
int word_list_insert (word_list_t wl, const char *word)
 insert a word into a word list More...
 
void word_list_foreach (const word_list_t wl, void(*fp)(char *))
 
void word_list_sort (word_list_t wl, int(*compar)(const void *, const void *))
 sort a list of words using comparison function
 
unsigned long word_list_count (const word_list_t wl)
 count the number of items in a word list More...
 
void word_list_inject (const word_list_t wl, void *data, int(*fnptr)(void *, const char *))
 

Detailed Description

data structure and associated functions to work with lists of words

Typedef Documentation

typedef struct word_list* word_list_t

object encapsulating a list of words

Function Documentation

unsigned long word_list_count ( const word_list_t  wl)

count the number of items in a word list

Parameters
wlthe word list
Returns
the number of items in word list wl
word_list_t word_list_create ( size_t  n)

create a new word list

Parameters
ninitial size of word list
Returns
a freshly allocated word_list_t

initialization performs dynamic memory allocation. It is the caller's responsibility to call word_list_free on the returned word_list_t object when it is no longer needed.

void word_list_foreach ( const word_list_t  wl,
void(*)(char *)  fp 
)

apply a function for each item in word list

void word_list_free ( word_list_t  words)

free the memory associated with a word list

Parameters
wordsNULL terminated array of char*
void word_list_inject ( const word_list_t  wl,
void *  data,
int(*)(void *, const char *)  fnptr 
)

accumulate all values in wl to data

accumulate each item with data by passing each to fnptr

Parameters
datainital value
fnptra pointer to the function defining the operation to perform
int word_list_insert ( word_list_t  wl,
const char *  word 
)

insert a word into a word list

Returns
0 on successful insert