dslib.h File Reference
#include "bstr.h"
Go to the source code of this file.
Data Structures |
struct | list_t |
struct | list_linked_element_t |
struct | list_linked_t |
struct | list_array_t |
struct | table_t |
Defines |
#define | list_push(L, E) (L)->push(L, E) |
#define | list_pop(L) (L)->pop(L) |
#define | list_empty(L) (L)->empty(L) |
#define | list_get(L, N) (L)->get((list_t *)L, N) |
#define | list_replace(L, N, E) (L)->replace((list_t *)L, N, E) |
#define | list_add(L, N) (L)->push(L, N) |
#define | list_size(L) (L)->size(L) |
#define | list_iterator_reset(L) (L)->iterator_reset(L) |
#define | list_iterator_next(L) (L)->iterator_next(L) |
#define | list_destroy(L) (*(L))->destroy(L) |
#define | list_shift(L) (L)->shift(L) |
#define | LIST_COMMON |
Typedefs |
typedef struct list_t | list_t |
typedef struct list_array_t | list_array_t |
typedef struct
list_linked_element_t | list_linked_element_t |
typedef struct list_linked_t | list_linked_t |
typedef struct table_t | table_t |
Functions |
list_t * | list_linked_create (void) |
void | list_linked_destroy (list_linked_t **_l) |
list_t * | list_array_create (size_t size) |
void | list_array_iterator_reset (list_array_t *l) |
void * | list_array_iterator_next (list_array_t *l) |
void | list_array_destroy (list_array_t **_l) |
table_t * | table_create (size_t size) |
int | table_add (table_t *, bstr *, void *) |
int | table_addn (table_t *, bstr *, void *) |
void | table_set (table_t *, bstr *, void *) |
void * | table_get (const table_t *, const bstr *) |
void * | table_get_c (const table_t *, const char *) |
void | table_iterator_reset (table_t *) |
bstr * | table_iterator_next (table_t *, void **) |
size_t | table_size (const table_t *t) |
void | table_destroy (table_t **) |
void | table_clear (table_t *) |
Detailed Description
- Author:
- Ivan Ristic <ivanr@webkreator.com>
Define Documentation
#define list_add |
( |
L, |
|
|
N |
|
) |
(L)->push(L, N) |
Value:int (*push)(list_t *, void *); \
void *(*pop)(list_t *); \
int (*empty)(const list_t *); \
void *(*get)(const list_t *, size_t index); \
int (*replace)(list_t *, size_t index, void *); \
size_t (*size)(const list_t *); \
void (*iterator_reset)(list_t *); \
void *(*iterator_next)(list_t *); \
void (*destroy)(list_t **); \
void *(*shift)(list_t *)
#define list_destroy |
( |
L |
|
) |
(*(L))->destroy(L) |
#define list_empty |
( |
L |
|
) |
(L)->empty(L) |
#define list_get |
( |
L, |
|
|
N |
|
) |
(L)->get((list_t *)L, N) |
#define list_iterator_next |
( |
L |
|
) |
(L)->iterator_next(L) |
#define list_iterator_reset |
( |
L |
|
) |
(L)->iterator_reset(L) |
#define list_pop |
( |
L |
|
) |
(L)->pop(L) |
#define list_push |
( |
L, |
|
|
E |
|
) |
(L)->push(L, E) |
#define list_replace |
( |
L, |
|
|
N, |
|
|
E |
|
) |
(L)->replace((list_t *)L, N, E) |
#define list_shift |
( |
L |
|
) |
(L)->shift(L) |
#define list_size |
( |
L |
|
) |
(L)->size(L) |
Typedef Documentation
Function Documentation
list_t* list_array_create |
( |
size_t |
size |
) |
|
Create new array-based list.
- Parameters:
-
- Returns:
- newly allocated list (list_t)
Free the memory occupied by this list. This function assumes the data elements were freed beforehand.
- Parameters:
-
Advance to the next list value.
- Parameters:
-
- Returns:
- the next list value, or NULL if there aren't more elements left to iterate over or if the element itself is NULL
Reset the list iterator.
- Parameters:
-
list_t* list_linked_create |
( |
void |
|
) |
|
Create a new linked list.
- Returns:
- a pointer to the newly created list (list_t), or NULL on memory allocation failure
Destroy list. This function will not destroy any of the data stored in it. You'll have to do that manually beforehand.
- Parameters:
-
int table_addn |
( |
table_t * |
table, |
|
|
bstr * |
key, |
|
|
void * |
element | |
|
) |
| | |
Add a new table element. This function currently makes a copy of the key, which is inefficient.
- Parameters:
-
void table_clear |
( |
table_t * |
table |
) |
|
Remove all elements from the table.
- Parameters:
-
table_t* table_create |
( |
size_t |
size |
) |
|
Create a new table structure.
- Parameters:
-
- Returns:
- newly created table_t
void table_destroy |
( |
table_t ** |
_table |
) |
|
Destroy a table.
- Parameters:
-
void* table_get |
( |
const table_t * |
table, |
|
|
const bstr * |
key | |
|
) |
| | |
Retrieve the first element in the table with the given key.
- Parameters:
-
- Returns:
- table element, or NULL if not found
void* table_get_c |
( |
const table_t * |
table, |
|
|
const char * |
cstr | |
|
) |
| | |
- Parameters:
-
| table | |
| key | Retrieve the first element in the table with the given key (as a NUL-terminated string). |
| table | |
| cstr | |
- Returns:
- table element, or NULL if not found
bstr* table_iterator_next |
( |
table_t * |
t, |
|
|
void ** |
data | |
|
) |
| | |
Advance to the next table element.
- Parameters:
-
- Returns:
- pointer to the key and the element if there is a next element, NULL otherwise
void table_iterator_reset |
( |
table_t * |
table |
) |
|
Reset the table iterator.
- Parameters:
-
size_t table_size |
( |
const table_t * |
table |
) |
|
Returns the size of the table.
- Parameters:
-
- Returns:
- table size