Diffusion C API
6.2.9
|
A simple linked list implementation. More...
Data Structures | |
struct | list_node_s |
Structure representing a node in a linked list. More... | |
struct | list_s |
A structure defining a linked list. More... | |
Typedefs | |
typedef struct list_node_s | LIST_NODE_T |
Structure representing a node in a linked list. | |
typedef struct list_s | LIST_T |
A structure defining a linked list. | |
Functions | |
LIST_T * | list_create (void) |
Create a new linked list. More... | |
int | list_get_size (const LIST_T *list) |
Returns the number of entries in the list. More... | |
LIST_T * | list_dup (const LIST_T *list, void *(*copy_fn)(void *)) |
Copy a list. More... | |
void | list_free (LIST_T *list, void(*free_fn)(void *)) |
Free memory allocated to a linked list. More... | |
void | list_of_lists_free (LIST_T *list, void(*free_fn)(void *)) |
Free memory allocated to a linked list containing linked lists. More... | |
void | list_insert (LIST_T *list, LIST_NODE_T *where, void *data) |
Insert a node before another in the list. More... | |
void | list_append (LIST_T *list, LIST_NODE_T *where, void *data) |
Append a node after another in the list. More... | |
void | list_insert_first (LIST_T *list, void *data) |
Insert a node into the first position in the list. More... | |
void | list_append_last (LIST_T *list, void *data) |
Append a node to the last position in the list. More... | |
void * | list_get_data_first (const LIST_T *list) |
Return the node data of the first element in the list, or NULL if not possible. More... | |
void * | list_get_data_last (const LIST_T *list) |
Return the node data of the last element in the list, or NULL if not possible. More... | |
void * | list_get_data_indexed (const LIST_T *list, const int index) |
Return the node data of the nth element in the list, or NULL if not possible. More... | |
void | list_append_list (LIST_T *dst, const LIST_T *src) |
Appends list src to list dst. More... | |
A simple linked list implementation.
Copyright © 2014, 2015 Push Technology Ltd., All Rights Reserved.
Use is subject to license terms.
NOTICE: All information contained herein is, and remains the property of Push Technology. The intellectual and technical concepts contained herein are proprietary to Push Technology and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law.
void list_append | ( | LIST_T * | list, |
LIST_NODE_T * | where, | ||
void * | data | ||
) |
Append a node after another in the list.
list | The list in which to append the node. |
where | The node to append after. |
data | The data to be contained in the new node. |
void list_append_last | ( | LIST_T * | list, |
void * | data | ||
) |
Append a node to the last position in the list.
list | The list in which to append the node. |
data | The data to be contained in the new node. |
Appends list src to list dst.
Does not copy any data, but links the two lists together.
dst | The list to be appended to. |
src | The list to append. |
LIST_T* list_create | ( | void | ) |
Create a new linked list.
LIST_T * | Returns a pointer to a LIST_T structure. |
Copy a list.
list | The list to be copied. |
copy_fn | A function to be used to copy the data in each node. |
LIST_T * | A copy of the list. |
void list_free | ( | LIST_T * | list, |
void(*)(void *) | free_fn | ||
) |
Free memory allocated to a linked list.
list | The list to free |
free_fn | A function used to free the contents of a list node contents, or NULL if the contents are not to be freed. |
void* list_get_data_first | ( | const LIST_T * | list | ) |
Return the node data of the first element in the list, or NULL if not possible.
list | The list to be accessed. |
void * | The data contained in the first list node, or NULL. |
void* list_get_data_indexed | ( | const LIST_T * | list, |
const int | index | ||
) |
Return the node data of the nth element in the list, or NULL if not possible.
list | The list to be accessed. |
index | The index of the node in the list to access. |
void * | The data contained in the list node with the given index, or NULL. |
void* list_get_data_last | ( | const LIST_T * | list | ) |
Return the node data of the last element in the list, or NULL if not possible.
list | The list to be accessed. |
void * | The data contained in the last list node, or NULL. |
int list_get_size | ( | const LIST_T * | list | ) |
Returns the number of entries in the list.
the | number of entries. -1 if list is NULL. |
void list_insert | ( | LIST_T * | list, |
LIST_NODE_T * | where, | ||
void * | data | ||
) |
Insert a node before another in the list.
list | The list in which to insert the node. |
where | The node to insert before. |
data | The data to be contained in the new node. |
void list_insert_first | ( | LIST_T * | list, |
void * | data | ||
) |
Insert a node into the first position in the list.
list | The list in which to insert the node. |
data | The data to be contained in the new node. |
void list_of_lists_free | ( | LIST_T * | list, |
void(*)(void *) | free_fn | ||
) |
Free memory allocated to a linked list containing linked lists.
This function should be used to free the list retrieved from:
list | The list to free |
free_fn | A function used to free the contents of a list node contents, or NULL if the contents are not to be freed. |