Diffusion C API  5.9.24
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
list.h File Reference

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_Tlist_create (void)
 Create a new linked list. More...
 
LIST_Tlist_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_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...
 

Detailed Description

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.

Function Documentation

void list_append ( LIST_T list,
LIST_NODE_T where,
void *  data 
)

Append a node after another in the list.

Parameters
listThe list in which to append the node.
whereThe node to append after.
dataThe 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.

Parameters
listThe list in which to append the node.
dataThe data to be contained in the new node.
void list_append_list ( LIST_T dst,
const LIST_T src 
)

Appends list src to list dst.

Does not copy any data, but links the two lists together.

Parameters
dstThe list to be appended to.
srcThe list to append.
LIST_T* list_create ( void  )

Create a new linked list.

Return values
LIST_T *Returns a pointer to a LIST_T structure.
LIST_T* list_dup ( const LIST_T list,
void *(*)(void *)  copy_fn 
)

Copy a list.

Parameters
listThe list to be copied.
copy_fnA function to be used to copy the data in each node.
Return values
LIST_T *A copy of the list.
void list_free ( LIST_T list,
void(*)(void *)  free_fn 
)

Free memory allocated to a linked list.

Parameters
listThe list to free
free_fnA 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.

Parameters
listThe list to be accessed.
Return values
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.

Parameters
listThe list to be accessed.
indexThe index of the node in the list to access.
Return values
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.

Parameters
listThe list to be accessed.
Return values
void *The data contained in the last list node, or NULL.
void list_insert ( LIST_T list,
LIST_NODE_T where,
void *  data 
)

Insert a node before another in the list.

Parameters
listThe list in which to insert the node.
whereThe node to insert before.
dataThe 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.

Parameters
listThe list in which to insert the node.
dataThe data to be contained in the new node.