Connectivity Middleware Utilities Library

General Description

This is a generic linked list library with helper functions to add, insert, delete and find nodes in a list.

Functions

cy_rslt_t cy_linked_list_init (cy_linked_list_t *list)
 Initialize list. More...
 
cy_rslt_t cy_linked_list_deinit (cy_linked_list_t *list)
 De-initialize list. More...
 
cy_rslt_t cy_linked_list_get_count (cy_linked_list_t *list, uint32_t *count)
 Get the count for number of nodes present in list. More...
 
cy_rslt_t cy_linked_list_set_node_data (cy_linked_list_node_t *node, const void *data)
 Set the data for linked list node. More...
 
cy_rslt_t cy_linked_list_get_front_node (cy_linked_list_t *list, cy_linked_list_node_t **front_node)
 Get the front node in list. More...
 
cy_rslt_t cy_linked_list_get_rear_node (cy_linked_list_t *list, cy_linked_list_node_t **rear_node)
 Get the rear node in list. More...
 
cy_rslt_t cy_linked_list_find_node (cy_linked_list_t *list, cy_linked_list_compare_callback_t callback, void *user_data, cy_linked_list_node_t **node_found)
 Find particular node in the list. More...
 
cy_rslt_t cy_linked_list_insert_node_at_front (cy_linked_list_t *list, cy_linked_list_node_t *node)
 Insert node at the front of the list. More...
 
cy_rslt_t cy_linked_list_insert_node_at_rear (cy_linked_list_t *list, cy_linked_list_node_t *node)
 Insert node at the rear of the list. More...
 
cy_rslt_t cy_linked_list_insert_node_before (cy_linked_list_t *list, cy_linked_list_node_t *reference_node, cy_linked_list_node_t *node_to_insert)
 Insert node before reference node. More...
 
cy_rslt_t cy_linked_list_insert_node_after (cy_linked_list_t *list, cy_linked_list_node_t *reference_node, cy_linked_list_node_t *node_to_insert)
 Insert node after reference node. More...
 
cy_rslt_t cy_linked_list_remove_node (cy_linked_list_t *list, cy_linked_list_node_t *node)
 Remove the node from the list. More...
 
cy_rslt_t cy_linked_list_remove_node_from_front (cy_linked_list_t *list, cy_linked_list_node_t **removed_node)
 Remove node from front of the list. More...
 
cy_rslt_t cy_linked_list_remove_node_from_rear (cy_linked_list_t *list, cy_linked_list_node_t **removed_node)
 Remove node from rear of the list. More...
 

Function Documentation

◆ cy_linked_list_init()

cy_rslt_t cy_linked_list_init ( cy_linked_list_t list)

Initialize list.

Parameters
[in]list- Pointer to a list
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG

◆ cy_linked_list_deinit()

cy_rslt_t cy_linked_list_deinit ( cy_linked_list_t list)

De-initialize list.

Parameters
[in]list- Pointer to a list
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG

◆ cy_linked_list_get_count()

cy_rslt_t cy_linked_list_get_count ( cy_linked_list_t list,
uint32_t *  count 
)

Get the count for number of nodes present in list.

Parameters
[in]list- Pointer to an initialized list
[out]count- number of nodes present in list
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG

◆ cy_linked_list_set_node_data()

cy_rslt_t cy_linked_list_set_node_data ( cy_linked_list_node_t *  node,
const void *  data 
)

Set the data for linked list node.

Parameters
[in]node- linked list node for which data need to be set
[in]data- data value for node
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG

◆ cy_linked_list_get_front_node()

cy_rslt_t cy_linked_list_get_front_node ( cy_linked_list_t list,
cy_linked_list_node_t **  front_node 
)

Get the front node in list.

Parameters
[in]list- Pointer to an initialized list
[out]front_node- front node in the list
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG

◆ cy_linked_list_get_rear_node()

cy_rslt_t cy_linked_list_get_rear_node ( cy_linked_list_t list,
cy_linked_list_node_t **  rear_node 
)

Get the rear node in list.

Parameters
[in]list- Pointer to an initialized list
[out]rear_node- rear node in the list
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG

◆ cy_linked_list_find_node()

cy_rslt_t cy_linked_list_find_node ( cy_linked_list_t list,
cy_linked_list_compare_callback_t  callback,
void *  user_data,
cy_linked_list_node_t **  node_found 
)

Find particular node in the list.

Parameters
[in]list- Pointer to an initialized list
[in]callback- callback to compare node data in the list
[in]user_data- user data
[out]node_found- node_found in the list
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG
  • CY_RSLT_LINKED_LIST_NOT_FOUND

◆ cy_linked_list_insert_node_at_front()

cy_rslt_t cy_linked_list_insert_node_at_front ( cy_linked_list_t list,
cy_linked_list_node_t *  node 
)

Insert node at the front of the list.

Parameters
[in]list- Pointer to an initialized list
[in]node- node to be added at the front of the list
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG

◆ cy_linked_list_insert_node_at_rear()

cy_rslt_t cy_linked_list_insert_node_at_rear ( cy_linked_list_t list,
cy_linked_list_node_t *  node 
)

Insert node at the rear of the list.

Parameters
[in]list- Pointer to an initialized list
[in]node- node to be added at the rear of the list
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG

◆ cy_linked_list_insert_node_before()

cy_rslt_t cy_linked_list_insert_node_before ( cy_linked_list_t list,
cy_linked_list_node_t *  reference_node,
cy_linked_list_node_t *  node_to_insert 
)

Insert node before reference node.

Parameters
[in]list- Pointer to an initialized list
[in]reference_node- Pointer to a node before which you want to add new node
[in]node_to_insert- Pointer to a node to be inserted
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG
  • CY_RSLT_LINKED_LIST_NOT_FOUND

◆ cy_linked_list_insert_node_after()

cy_rslt_t cy_linked_list_insert_node_after ( cy_linked_list_t list,
cy_linked_list_node_t *  reference_node,
cy_linked_list_node_t *  node_to_insert 
)

Insert node after reference node.

Parameters
[in]list- Pointer to an initialized list
[in]reference_node- Pointer to a node after which you want to add new node
[in]node_to_insert- Pointer to a node to be inserted
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG
  • CY_RSLT_LINKED_LIST_NOT_FOUND

◆ cy_linked_list_remove_node()

cy_rslt_t cy_linked_list_remove_node ( cy_linked_list_t list,
cy_linked_list_node_t *  node 
)

Remove the node from the list.

Parameters
[in]list- Pointer to an initialized list
[in]node- Pointer to a linked list node to be deleted
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG
  • CY_RSLT_LINKED_LIST_NOT_FOUND

◆ cy_linked_list_remove_node_from_front()

cy_rslt_t cy_linked_list_remove_node_from_front ( cy_linked_list_t list,
cy_linked_list_node_t **  removed_node 
)

Remove node from front of the list.

Parameters
[in]list- Pointer to an initialized list
[out]removed_node- removed node
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG
  • CY_RSLT_LINKED_LIST_NOT_FOUND

◆ cy_linked_list_remove_node_from_rear()

cy_rslt_t cy_linked_list_remove_node_from_rear ( cy_linked_list_t list,
cy_linked_list_node_t **  removed_node 
)

Remove node from rear of the list.

Parameters
[in]list- Pointer to an initialized list
[out]removed_node- removed node
Returns
on success - CY_RSLT_SUCCESS on failure - CY_RSLT_LINKED_LIST_BADARG
  • CY_RSLT_LINKED_LIST_NOT_FOUND