CWB
Macros | Functions
list.c File Reference
#include "globals.h"
#include "cl.h"
#include "macros.h"
#include "list.h"

Macros

#define LUMPSIZE   64
 Default size of steps (lumps) by which auto-growing lists are extended. More...
 

Functions

cl_int_list cl_new_int_list (void)
 Creates a new cl_int_list object. More...
 
void cl_delete_int_list (cl_int_list l)
 Deletes a cl_int_list object. More...
 
void cl_int_list_lumpsize (cl_int_list l, int s)
 Sets the lumpsize of a cl_int_list object. More...
 
int cl_int_list_size (cl_int_list l)
 Gets the current size of a cl_int_list object (number of elements on the list). More...
 
int cl_int_list_get (cl_int_list l, int n)
 Retrieves an element from a cl_int_list object. More...
 
void cl_int_list_set (cl_int_list l, int n, int val)
 Sets an integer on a cl_int_list object. More...
 
void cl_int_list_append (cl_int_list l, int val)
 Appends an integer to the end of a cl_int_list object. More...
 
int cl_int_list_intcmp (const void *a, const void *b)
 comparison function for int list sort : non-exported More...
 
void cl_int_list_qsort (cl_int_list l)
 Sorts a cl_int_list object. More...
 
cl_string_list cl_new_string_list (void)
 Creates a new cl_string_list object. More...
 
void cl_delete_string_list (cl_string_list l)
 Deletes a cl_string_list object. More...
 
void cl_free_string_list (cl_string_list l)
 Frees all the strings in the cl_string_list object. More...
 
void cl_string_list_lumpsize (cl_string_list l, int s)
 Sets the lumpsize of a cl_string_list object. More...
 
int cl_string_list_size (cl_string_list l)
 Gets the current size of a cl_string_list object (number of elements on the list). More...
 
char * cl_string_list_get (cl_string_list l, int n)
 Retrieves an element from a cl_string_list object. More...
 
void cl_string_list_set (cl_string_list l, int n, char *val)
 Sets a string pointer on a cl_string_list object. More...
 
void cl_string_list_append (cl_string_list l, char *val)
 Appends a string pointer to the end of a cl_string_list object. More...
 
int cl_string_list_strcmp (const void *a, const void *b)
 comparison function for string list sort : non-exported More...
 
void cl_string_list_qsort (cl_string_list l)
 Sorts a cl_string_list object. More...
 

Macro Definition Documentation

#define LUMPSIZE   64

Default size of steps (lumps) by which auto-growing lists are extended.

List functions automatically extend lists in steps of at least LUMPSIZE cells (to avoid too frequent reallocs).

This can be configured on a per-list-object basis with cl_int_list_lumpsize() and cl_string_list_lumpsize().

See also
cl_int_list_lumpsize
cl_string_list_lumpsize
_cl_int_list::lumpsize
_cl_string_list::lumpsize

Referenced by cl_int_list_lumpsize(), cl_new_int_list(), cl_new_string_list(), and cl_string_list_lumpsize().

Function Documentation

void cl_delete_int_list ( cl_int_list  l)

Deletes a cl_int_list object.

References cl_free, and _cl_int_list::data.

void cl_delete_string_list ( cl_string_list  l)

Deletes a cl_string_list object.

References cl_free, and _cl_string_list::data.

Referenced by cl_make_set(), encode_parse_options(), and main().

void cl_free_string_list ( cl_string_list  l)

Frees all the strings in the cl_string_list object.

References cl_free, _cl_string_list::data, and _cl_string_list::size.

Referenced by main().

void cl_int_list_append ( cl_int_list  l,
int  val 
)

Appends an integer to the end of a cl_int_list object.

References cl_int_list_set(), and _cl_int_list::size.

int cl_int_list_get ( cl_int_list  l,
int  n 
)

Retrieves an element from a cl_int_list object.

Parameters
lThe list to search.
nThe element to retrieve.
Returns
The n'th integer on the list, or 0 if there is no n'th integer.

References _cl_int_list::data, and _cl_int_list::size.

int cl_int_list_intcmp ( const void *  a,
const void *  b 
)

comparison function for int list sort : non-exported

Referenced by cl_int_list_qsort().

void cl_int_list_lumpsize ( cl_int_list  l,
int  s 
)

Sets the lumpsize of a cl_int_list object.

See also
LUMPSIZE
Parameters
lThe cl_int_list.
sThe new lumpsize.

References _cl_int_list::lumpsize, and LUMPSIZE.

void cl_int_list_qsort ( cl_int_list  l)

Sorts a cl_int_list object.

The list of integers are sorted into ascending order.

References cl_int_list_intcmp(), _cl_int_list::data, and _cl_int_list::size.

void cl_int_list_set ( cl_int_list  l,
int  n,
int  val 
)

Sets an integer on a cl_int_list object.

The n'th element on the list is set to val, and the list is auto-extended if necessary.

References _cl_int_list::allocated, cl_realloc(), _cl_int_list::data, _cl_int_list::lumpsize, and _cl_int_list::size.

Referenced by cl_int_list_append().

int cl_int_list_size ( cl_int_list  l)

Gets the current size of a cl_int_list object (number of elements on the list).

References _cl_int_list::size.

cl_int_list cl_new_int_list ( void  )
cl_string_list cl_new_string_list ( void  )
void cl_string_list_append ( cl_string_list  l,
char *  val 
)

Appends a string pointer to the end of a cl_string_list object.

References cl_string_list_set(), and _cl_string_list::size.

Referenced by cl_corpus_list_attributes(), cl_make_set(), cwbci_check_line(), encode_parse_options(), encode_scan_directory(), and range_declare().

char* cl_string_list_get ( cl_string_list  l,
int  n 
)

Retrieves an element from a cl_string_list object.

Parameters
lThe list to search.
nThe element to retrieve.
Returns
The n'th string on the list, or NULL if there is no n'th string. Note that the returned pointer references the ACTUAL DATA in the list - not a copy, if you want a copy you must make one yourself.

References _cl_string_list::data, and _cl_string_list::size.

Referenced by cl_make_set(), cwbci_check_line(), encode_get_input_line(), encode_parse_options(), main(), range_close(), range_open(), and range_print_registry_line().

void cl_string_list_lumpsize ( cl_string_list  l,
int  s 
)

Sets the lumpsize of a cl_string_list object.

See also
LUMPSIZE
Parameters
lThe cl_string_list.
sThe new lumpsize.

References LUMPSIZE, and _cl_string_list::lumpsize.

void cl_string_list_qsort ( cl_string_list  l)

Sorts a cl_string_list object.

The list of strings is sorted using cl_strcmp().

See also
cl_strcmp

References cl_string_list_strcmp(), _cl_string_list::data, and _cl_string_list::size.

Referenced by cl_make_set(), and encode_scan_directory().

void cl_string_list_set ( cl_string_list  l,
int  n,
char *  val 
)

Sets a string pointer on a cl_string_list object.

The n'th element on the list is set to val, and the list is auto-extended if necessary.

References _cl_string_list::allocated, cl_realloc(), _cl_string_list::data, _cl_string_list::lumpsize, and _cl_string_list::size.

Referenced by cl_string_list_append().

int cl_string_list_size ( cl_string_list  l)

Gets the current size of a cl_string_list object (number of elements on the list).

References _cl_string_list::size.

Referenced by cl_make_set(), cwbci_check_line(), encode_parse_options(), main(), range_close(), range_open(), and range_print_registry_line().

int cl_string_list_strcmp ( const void *  a,
const void *  b 
)

comparison function for string list sort : non-exported

References cl_strcmp().

Referenced by cl_string_list_qsort().