SphinxBase
5prealpha
|
Generic linked-lists maintenance. More...
Go to the source code of this file.
Data Structures | |
struct | gnode_s |
A node in a generic list. More... | |
Macros | |
#define | gnode_ptr(g) ((g)->data.ptr) |
Head of a list of gnodes. More... | |
#define | gnode_int32(g) ((g)->data.i) |
#define | gnode_uint32(g) ((g)->data.ui) |
#define | gnode_float32(g) ((float32)(g)->data.fl) |
#define | gnode_float64(g) ((g)->data.fl) |
#define | gnode_next(g) ((g)->next) |
Typedefs | |
typedef struct gnode_s | gnode_t |
A node in a generic list. | |
typedef gnode_t * | glist_t |
Functions | |
SPHINXBASE_EXPORT glist_t | glist_add_ptr (glist_t g, void *ptr) |
Create and prepend a new list node, with the given user-defined data, at the HEAD of the given generic list. More... | |
SPHINXBASE_EXPORT glist_t | glist_add_int32 (glist_t g, int32 val) |
Create and prepend a new list node containing an integer. More... | |
SPHINXBASE_EXPORT glist_t | glist_add_uint32 (glist_t g, uint32 val) |
Create and prepend a new list node containing an unsigned integer. More... | |
SPHINXBASE_EXPORT glist_t | glist_add_float32 (glist_t g, float32 val) |
Create and prepend a new list node containing a single-precision float. More... | |
SPHINXBASE_EXPORT glist_t | glist_add_float64 (glist_t g, float64 val) |
Create and prepend a new list node containing a double-precision float. More... | |
SPHINXBASE_EXPORT gnode_t * | glist_insert_ptr (gnode_t *gn, void *ptr) |
Create and insert a new list node, with the given user-defined data, after the given generic node gn. More... | |
SPHINXBASE_EXPORT gnode_t * | glist_insert_int32 (gnode_t *gn, int32 val) |
Create and insert a new list node containing an integer. More... | |
SPHINXBASE_EXPORT gnode_t * | glist_insert_uint32 (gnode_t *gn, uint32 val) |
Create and insert a new list node containing an unsigned integer. More... | |
SPHINXBASE_EXPORT gnode_t * | glist_insert_float32 (gnode_t *gn, float32 val) |
Create and insert a new list node containing a single-precision float. More... | |
SPHINXBASE_EXPORT gnode_t * | glist_insert_float64 (gnode_t *gn, float64 val) |
Create and insert a new list node containing a double-precision float. More... | |
SPHINXBASE_EXPORT glist_t | glist_reverse (glist_t g) |
Reverse the order of the given glist. More... | |
SPHINXBASE_EXPORT int32 | glist_count (glist_t g) |
Count the number of element in a given link list. More... | |
SPHINXBASE_EXPORT void | glist_free (glist_t g) |
Free the given generic list; user-defined data contained within is not automatically freed. More... | |
SPHINXBASE_EXPORT gnode_t * | gnode_free (gnode_t *gn, gnode_t *pred) |
Free the given node, gn, of a glist, pred being its predecessor in the list. More... | |
SPHINXBASE_EXPORT gnode_t * | glist_tail (glist_t g) |
Return the last node in the given list. | |
Generic linked-lists maintenance.
Only insert at the head of the list. A convenient little linked-list package, but a double-edged sword: the user must keep track of the data type within the linked list elements. When it was first written, there was no selective deletions except to destroy the entire list. This is modified in later version.
(C++ would be good for this, but that's a double-edged sword as well.)
Definition in file glist.h.
#define gnode_ptr | ( | g | ) | ((g)->data.ptr) |
Create and prepend a new list node containing a single-precision float.
g | a link list |
val | a float32 vlaue |
Definition at line 110 of file glist.c.
References ckd_calloc, and gnode_s::next.
Create and prepend a new list node containing a double-precision float.
g | a link list |
val | a float64 vlaue |
Definition at line 122 of file glist.c.
References ckd_calloc, and gnode_s::next.
Create and prepend a new list node containing an integer.
g | a link list |
val | an integer value |
Definition at line 86 of file glist.c.
References ckd_calloc, and gnode_s::next.
Create and prepend a new list node, with the given user-defined data, at the HEAD of the given generic list.
Return the new list thus formed. g may be NULL to indicate an initially empty list.
g | a link list |
ptr | a pointer |
Definition at line 74 of file glist.c.
References ckd_calloc, and gnode_s::next.
Create and prepend a new list node containing an unsigned integer.
g | a link list |
val | an unsigned integer value |
Definition at line 98 of file glist.c.
References ckd_calloc, and gnode_s::next.
SPHINXBASE_EXPORT int32 glist_count | ( | glist_t | g | ) |
Count the number of element in a given link list.
g | input link list |
Definition at line 145 of file glist.c.
References gnode_s::next.
SPHINXBASE_EXPORT void glist_free | ( | glist_t | g | ) |
Free the given generic list; user-defined data contained within is not automatically freed.
The caller must have done that already.
Definition at line 133 of file glist.c.
References ckd_free(), and gnode_s::next.
Create and insert a new list node containing a single-precision float.
gn | a generic node which a value will be inserted after it |
val | float32 inserted |
Definition at line 230 of file glist.c.
References ckd_calloc, and gnode_s::next.
Create and insert a new list node containing a double-precision float.
gn | a generic node which a value will be inserted after it |
val | float64 inserted |
Definition at line 244 of file glist.c.
References ckd_calloc, and gnode_s::next.
Create and insert a new list node containing an integer.
gn | a generic node which a value will be inserted after it |
val | int32 inserted |
Definition at line 201 of file glist.c.
References ckd_calloc, and gnode_s::next.
Create and insert a new list node, with the given user-defined data, after the given generic node gn.
gn cannot be NULL. Return ptr to the newly created gnode_t.
gn | a generic node which ptr will be inserted after it |
ptr | pointer inserted |
Definition at line 187 of file glist.c.
References ckd_calloc, and gnode_s::next.
Create and insert a new list node containing an unsigned integer.
gn | a generic node which a value will be inserted after it |
val | uint32 inserted |
Definition at line 215 of file glist.c.
References ckd_calloc, and gnode_s::next.
Free the given node, gn, of a glist, pred being its predecessor in the list.
Return ptr to the next node in the list after the freed node.
Definition at line 257 of file glist.c.
References ckd_free(), and gnode_s::next.