AM263Px MCU+ SDK: Doubly Linked List

| AM263Px MCU+ SDK 26.00.00 |

Files | Data Structures | Functions | Typedefs | Macros
Doubly Linked List
APIs for Unibase Binding

## Introduction

## Files
file | ub_llist.h
| Doubly linked list.

## Data Structures
struct | ub_list_node
| ub_list node structure More...
struct | ub_list
| Link ub_list structure. More...

## Functions
void | ub_list_init (struct ub_list *ub_list)
| Initialize ub_list. More...
void | ub_list_clear (struct ub_list *ub_list, ub_list_node_clear_h node_clear, void *arg)
| Clear the ub_list without freeing any nodes. More...
void | ub_list_append (struct ub_list *ub_list, struct ub_list_node *node)
| Append a node at the end of the ub_list. More...
void | ub_list_prepend (struct ub_list *ub_list, struct ub_list_node *node)
| Append a node at the start of the ub_list. More...
void | ub_list_insert_before (struct ub_list *ub_list, struct ub_list_node *refnode, struct ub_list_node *node)
| Append a node before a reference node. More...
void | ub_list_insert_after (struct ub_list *ub_list, struct ub_list_node *refnode, struct ub_list_node *node)
| Append a node after a reference node. More...
void | ub_list_unlink (struct ub_list *ub_list, struct ub_list_node *node)
| Remove a node from the ub_list. More...
void | ub_list_sort (struct ub_list *ub_list, ub_list_sort_h *sh, void *arg)
| Sort entries in the ub_list based on comparator. More...
struct ub_list_node * | ub_list_apply (const struct ub_list *ub_list, bool fwd, ub_list_apply_h *ah, void *arg)
| Apply function to nodes in the ub_list. More...
struct ub_list_node * | ub_list_head (const struct ub_list *ub_list)
| Get first entry of the ub_list. More...
struct ub_list_node * | ub_list_tail (const struct ub_list *ub_list)
| Get last entry of the ub_list. More...
uint32_t | ub_list_count (const struct ub_list *ub_list)
| Get number of entries. More...
static void * | ub_list_nodedata (const struct ub_list_node *node)
| Get data of node. More...
static bool | ub_list_isempty (const struct ub_list *ub_list)
| Check if ub_list is empty. More...

## Typedefs
typedef void() | ub_list_node_clear_h(struct ub_list_node *node, void *arg)
| function to clean up node More...
typedef bool() | ub_list_sort_h(struct ub_list_node *node1, struct ub_list_node *node2, void *arg)
| Comparator function handler for nodes. More...
typedef bool() | ub_list_apply_h(struct ub_list_node *node, void *arg)
| Apply function handler for nodes. More...

## Macros
#define | UB_LIST_NODE_INIT {NULL, NULL, NULL}
| Initialize members of ub_list node. More...
#define | UB_LIST_INIT {NULL, NULL, 0}
| Initialize ub_list. More...
#define | UB_LIST_FOREACH_ITER(ub_list, node) (node) = ub_list_head((ub_list)); (node); (node) = (node)->next
| Traverse the ub_list. More...

## Macro Definition Documentation

## ◆ UB_LIST_NODE_INIT

#define UB_LIST_NODE_INIT {NULL, NULL, NULL}

Initialize members of ub_list node.

## ◆ UB_LIST_INIT

#define UB_LIST_INIT {NULL, NULL, 0}

Initialize ub_list.

## ◆ UB_LIST_FOREACH_ITER

#define UB_LIST_FOREACH_ITER | ( |  | ub_list,
|  |  | node
| ) |  | (node) = ub_list_head((ub_list)); (node); (node) = (node)->next

Traverse the ub_list.

## Typedef Documentation

## ◆ ub_list_node_clear_h

typedef void() ub_list_node_clear_h(struct ub_list_node *node, void *arg)

function to clean up node

Parameters

  node | node to be applied
  arg | clean up argument

## ◆ ub_list_sort_h

typedef bool() ub_list_sort_h(struct ub_list_node *node1, struct ub_list_node *node2, void *arg)

Comparator function handler for nodes.

Parameters

  node1 | first node
  node2 | second node
  arg | Comparison argument

Note
  the result must end up with all true, otherwise it goes to infinite loop

## ◆ ub_list_apply_h

typedef bool() ub_list_apply_h(struct ub_list_node *node, void *arg)

Apply function handler for nodes.

Parameters

  node | node to be applied
  arg | Apply argument

## Function Documentation

## ◆ ub_list_init()

void ub_list_init | ( | struct ub_list * | ub_list | ) |

Initialize ub_list.

Parameters

  ub_list | pointer to link ub_list structure

## ◆ ub_list_clear()

void ub_list_clear | ( | struct ub_list * | ub_list,
|  | ub_list_node_clear_h | node_clear,
|  | void * | arg
| ) |  |

Clear the ub_list without freeing any nodes.

Parameters

  ub_list | pointer to link ub_list structure
  node_clear | clean up callback fuction
  arg | clean up argument

## ◆ ub_list_append()

void ub_list_append | ( | struct ub_list * | ub_list,
|  | struct ub_list_node * | node
| ) |  |

Append a node at the end of the ub_list.

Parameters

  ub_list | Pointer to link ub_list structure
  node | entry to be appended

## ◆ ub_list_prepend()

void ub_list_prepend | ( | struct ub_list * | ub_list,
|  | struct ub_list_node * | node
| ) |  |

Append a node at the start of the ub_list.

Parameters

  ub_list | Pointer to link ub_list structure
  node | entry to be appended

## ◆ ub_list_insert_before()

void ub_list_insert_before | ( | struct ub_list * | ub_list,
|  | struct ub_list_node * | refnode,
|  | struct ub_list_node * | node
| ) |  |

Append a node before a reference node.

Parameters

  ub_list | Pointer to link ub_list structure
  refnode | Reference node
  node | entry to be inserted

## ◆ ub_list_insert_after()

void ub_list_insert_after | ( | struct ub_list * | ub_list,
|  | struct ub_list_node * | refnode,
|  | struct ub_list_node * | node
| ) |  |

Append a node after a reference node.

Parameters

  ub_list | Pointer to link ub_list structure
  refnode | Reference node
  node | entry to be appended

## ◆ ub_list_unlink()

void ub_list_unlink | ( | struct ub_list * | ub_list,
|  | struct ub_list_node * | node
| ) |  |

Remove a node from the ub_list.

Parameters

  ub_list | Pointer to link ub_list structure
  node | entry to be removed

## ◆ ub_list_sort()

void ub_list_sort | ( | struct ub_list * | ub_list,
|  | ub_list_sort_h * | sh,
|  | void * | arg
| ) |  |

Sort entries in the ub_list based on comparator.

Parameters

  ub_list | Pointer to link ub_list structure
  sh | Sort comparator handler
  arg | Sort argument

## ◆ ub_list_apply()

struct ub_list_node* ub_list_apply | ( | const struct ub_list * | ub_list,
|  | bool | fwd,
|  | ub_list_apply_h * | ah,
|  | void * | arg
| ) |  |

Apply function to nodes in the ub_list.

Parameters

  ub_list | Pointer to link ub_list structure
  fwd | Forward or reverse movement
  ah | Apply function handler
  arg | Apply argument

## ◆ ub_list_head()

struct ub_list_node* ub_list_head | ( | const struct ub_list * | ub_list | ) |

Get first entry of the ub_list.

Parameters

  ub_list | Pointer to link ub_list structure

## ◆ ub_list_tail()

struct ub_list_node* ub_list_tail | ( | const struct ub_list * | ub_list | ) |

Get last entry of the ub_list.

Parameters

  ub_list | Pointer to link ub_list structure

## ◆ ub_list_count()

uint32_t ub_list_count | ( | const struct ub_list * | ub_list | ) |

Get number of entries.

Parameters

  ub_list | Pointer to link ub_list structure

Returns
  number of entries

## ◆ ub_list_nodedata()

static void* ub_list_nodedata | ( | const struct ub_list_node * | node | ) |
| inlinestatic

Get data of node.

Parameters

  node | Node entry

Returns
  pointer to data

## ◆ ub_list_isempty()

static bool ub_list_isempty | ( | const struct ub_list * | ub_list | ) |
| inlinestatic

Check if ub_list is empty.

Parameters

  ub_list | Pointer to link ub_list structure

Returns
  true if node exist, otherwise false