CAEN Utility  2.0.2
Utilities for CAEN projects
Linked List

Utilities to implement linked list. More...

Data Structures

struct  c_listnode_t
 
struct  c_linkedlist_t
 

Typedefs

typedef struct c_listnode_t c_listnode_t
 
typedef int(* c_listdata_comparator_t) (const void *, const void *)
 

Functions

c_linkedlist_t c_linkedlist_create ()
 
c_listnode_tc_linkedlist_insert_after (c_listnode_t *node, void *newElement)
 
c_listnode_tc_linkedlist_insert_before (c_listnode_t *node, void *newElement)
 
c_Utility_ErrorCode_t c_linkedlist_insert_last (c_linkedlist_t *list, void *newElement)
 
c_Utility_ErrorCode_t c_linkedlist_insert_first (c_linkedlist_t *list, void *newElement)
 
void * c_linkedlist_delete (c_linkedlist_t *list, c_listnode_t *node)
 
void * c_linkedlist_delete_data_compare (c_linkedlist_t *list, void *data, c_listdata_comparator_t cmp)
 
void * c_linkedlist_delete_data (c_linkedlist_t *list, void *data)
 
void * c_linkedlist_delete_last (c_linkedlist_t *list)
 
void * c_linkedlist_delete_first (c_linkedlist_t *list)
 

Detailed Description

Utilities to implement linked list.

Author
Francesco Pepe
Date
2023

Typedef Documentation

◆ c_listnode_t

typedef struct c_listnode_t c_listnode_t

◆ c_listdata_comparator_t

typedef int(* c_listdata_comparator_t) (const void *, const void *)

Definition at line 63 of file CAENLinkedListTypes.h.

Function Documentation

◆ c_linkedlist_create()

c_linkedlist_t c_linkedlist_create ( )

Creates a new empty c_linkedlist_t

Returns
the new c_linkedlist_t

Definition at line 41 of file CAENLinkedList.c.

Here is the caller graph for this function:

◆ c_linkedlist_insert_after()

c_listnode_t* c_linkedlist_insert_after ( c_listnode_t node,
void *  newElement 
)

Inserts the given newElement AFTER the given node

Parameters
[in]nodethe node after which insert the new element
[in]newElementthe data of the new element to be added
Returns
the new c_listnode_t in case of success, NULL otherwise.

Definition at line 46 of file CAENLinkedList.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_linkedlist_insert_before()

c_listnode_t* c_linkedlist_insert_before ( c_listnode_t node,
void *  newElement 
)

Inserts the given newElement BEFORE the given node

Parameters
[in]nodethe node before which insert the new element
[in]newElementthe data of the new element to be added
Returns
the new c_listnode_t in case of success, NULL otherwise.

Definition at line 64 of file CAENLinkedList.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_linkedlist_insert_last()

c_Utility_ErrorCode_t c_linkedlist_insert_last ( c_linkedlist_t list,
void *  newElement 
)

Inserts the given newHead to the end of the list

Parameters
[in]linkthe linked list
[in]newElementthe data of the new element to be added
Returns
c_Utility_ErrorCode_Success in case of success, error code otherwise

Definition at line 82 of file CAENLinkedList.c.

Here is the call graph for this function:

◆ c_linkedlist_insert_first()

c_Utility_ErrorCode_t c_linkedlist_insert_first ( c_linkedlist_t list,
void *  newElement 
)

Inserts the given newHead to the begin of the list

Parameters
[in]linkthe linked list
[in]newElementthe data of the new element to be added
Returns
c_Utility_ErrorCode_Success in case of success, error code otherwise

Definition at line 100 of file CAENLinkedList.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_linkedlist_delete()

void* c_linkedlist_delete ( c_linkedlist_t list,
c_listnode_t node 
)

Deletes the given node, setting the references of previous and next elements and updating head and tail of linkedlist if necessary. NOTE: the data pointer is never free-ed.

Parameters
[in]listthe linked list
[in]nodethe node to be deleted
Returns
'node->data' in case of success, NULL otherwise

Definition at line 118 of file CAENLinkedList.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_linkedlist_delete_data_compare()

void* c_linkedlist_delete_data_compare ( c_linkedlist_t list,
void *  data,
c_listdata_comparator_t  cmp 
)

Deletes the first node starting from head whose 'data' field equals the given data. 'data' equality is evaluated using the given comparator. NOTE: references to head and tails are automatically updated. NOT automatically updated! NOTE: the data pointer is never free-ed.

Parameters
[in]listthe linked list
[in]datathe data to be found and removed from list
[in]cmpthe data comparator. Should return non-zero when its two arguments are considered equal. NOTE: i-th element of list is passed to cmp as first argument, given 'data' as second.
Returns
'data' in case of success, NULL otherwise

Definition at line 143 of file CAENLinkedList.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_linkedlist_delete_data()

void* c_linkedlist_delete_data ( c_linkedlist_t list,
void *  data 
)

Deletes the first node starting from head whose 'data' field equals the given data. NOTE: references to head and tails are automatically updated. NOT automatically updated! NOTE: the data pointer is never free-ed.

Parameters
[in]listthe linked list
[in]datathe data to be found and removed from list
Returns
'data' in case of success, NULL otherwise

Definition at line 155 of file CAENLinkedList.c.

Here is the call graph for this function:

◆ c_linkedlist_delete_last()

void* c_linkedlist_delete_last ( c_linkedlist_t list)

Deletes the last element of the given c_linkedlist_t. NOTE: the data pointer is never free-ed.

Parameters
[in]listthe linked list
Returns
'data' filed of the removed element in case of success, NULL otherwise

Definition at line 159 of file CAENLinkedList.c.

Here is the call graph for this function:

◆ c_linkedlist_delete_first()

void* c_linkedlist_delete_first ( c_linkedlist_t list)

Deletes the first element of the given c_linkedlist_t. NOTE: the data pointer is never free-ed.

Parameters
[in]listthe linked list
Returns
'data' filed of the removed element in case of success, NULL otherwise

Definition at line 174 of file CAENLinkedList.c.

Here is the call graph for this function:
Here is the caller graph for this function: