libSBML C API
libSBML 5.8.0 C API
|
Simple, generic list utility class.
Macros | |
#define | List_freeItems(list, free_item, type) |
Frees the items in the given List. More... | |
Typedefs | |
typedef int(* | ListItemComparator )(const void *item1, const void *item2) |
ListItemComparator. More... | |
typedef int(* | ListItemPredicate )(const void *item) |
ListItemPredicate. More... | |
typedef struct ListNode | ListNode_t |
Functions | |
void | List_add (List_t *lst, void *item) |
unsigned int | List_countIf (const List_t *lst, ListItemPredicate predicate) |
List_t * | List_create (void) |
void * | List_find (const List_t *lst, const void *item1, ListItemComparator comparator) |
List_t * | List_findIf (const List_t *lst, ListItemPredicate predicate) |
void | List_free (List_t *lst) |
void * | List_get (const List_t *lst, unsigned int n) |
void | List_prepend (List_t *lst, void *item) |
void * | List_remove (List_t *lst, unsigned int n) |
unsigned int | List_size (const List_t *lst) |
ListNode_t * | ListNode_create (void *item) |
void | ListNode_free (ListNode_t *node) |
#define List_freeItems | ( | list, | |
free_item, | |||
type | |||
) |
Frees the items in the given List.
Iterates over the items in this List and frees each one in turn by calling the passed-in 'void free_item(type *)' function.
The List itself will not be freed and so may be re-used. To free the List, use the destructor.
While the function prototype cannot be expressed precisely in C syntax, it is roughly:
where type
is a C type resolved at compile time.
Believe it or not, defining List_freeItems() as a macro is actually more type safe than can be acheived with straight C. That is, in C, the free_item() function would need to take a void pointer argument, requiring any type safe XXX_free() functions to be re-written to be less safe.
As with all line-continuation macros, compile-time errors will still report the correct line number.
typedef int(* ListItemComparator)(const void *item1, const void *item2) |
ListItemComparator.
This is a typedef for a pointer to a function that compares two list items. The return value semantics are the same as for the C library function strcmp:
item1
< item2
item1
== item2
item1
> item2
typedef int(* ListItemPredicate)(const void *item) |
ListItemPredicate.
This is a typedef for a pointer to a function that takes a List item and returns nonzero (for true) or zero (for false).
typedef struct ListNode ListNode_t |
void List_add | ( | List_t * | lst, |
void * | item | ||
) |
unsigned int List_countIf | ( | const List_t * | lst, |
ListItemPredicate | predicate | ||
) |
List_t* List_create | ( | void | ) |
void* List_find | ( | const List_t * | lst, |
const void * | item1, | ||
ListItemComparator | comparator | ||
) |
List_t* List_findIf | ( | const List_t * | lst, |
ListItemPredicate | predicate | ||
) |
void List_free | ( | List_t * | lst | ) |
void* List_get | ( | const List_t * | lst, |
unsigned int | n | ||
) |
void List_prepend | ( | List_t * | lst, |
void * | item | ||
) |
void* List_remove | ( | List_t * | lst, |
unsigned int | n | ||
) |
unsigned int List_size | ( | const List_t * | lst | ) |
ListNode_t* ListNode_create | ( | void * | item | ) |
void ListNode_free | ( | ListNode_t * | node | ) |