|
| typedef int32_t(* | f_cmp) (void *data1, void *data2) |
| | Prototype of the compare function.
|
| |
|
Each function interacting with the list have one of the following formats.
Aditionaly they may have one more parametere for specific functionalities.
In the Iterator functions, the list reference is replaced by the iterator's one.
|
| typedef int32_t(* | f_add) (struct no_os_list_desc *list_desc, void *data) |
| | Add an element in the list.
|
| |
| typedef int32_t(* | f_edit) (struct no_os_list_desc *list_desc, void *new_data) |
| | Edit an element in the list. The content is replaced by new_data.
|
| |
| typedef int32_t(* | f_read) (struct no_os_list_desc *list_desc, void **data) |
| | Read an element from the list.
|
| |
| typedef int32_t(* | f_get) (struct no_os_list_desc *list_desc, void **data) |
| | Read and remove an element from the list.
|
| |
|
| int32_t | no_os_list_init (struct no_os_list_desc **list_desc, enum no_os_adapter_type type, f_cmp comparator) |
| |
| int32_t | no_os_list_remove (struct no_os_list_desc *list_desc) |
| |
| int32_t | no_os_list_get_size (struct no_os_list_desc *list_desc, uint32_t *out_size) |
| |
|
An iterator is used to iterate through the list. For a list, any number of iterators can be created. All must be removed before removing a list.
|
| int32_t | no_os_iterator_init (struct no_os_iterator **iter, struct no_os_list_desc *list_desc, bool start) |
| |
| int32_t | no_os_iterator_remove (struct no_os_iterator *iter) |
| |
| int32_t | no_os_iterator_move (struct no_os_iterator *iter, int32_t steps) |
| |
| int32_t | no_os_iterator_move_to_idx (struct no_os_iterator *iter, int32_t idx) |
| |
| int32_t | no_os_iterator_find (struct no_os_iterator *iter, void *cmp_data) |
| |
| int32_t | no_os_iterator_insert (struct no_os_iterator *iter, void *data, bool after) |
| |
| int32_t | no_os_iterator_edit (struct no_os_iterator *iter, void *new_data) |
| |
| int32_t | no_os_iterator_read (struct no_os_iterator *iter, void **data) |
| |
| int32_t | no_os_iterator_get (struct no_os_iterator *iter, void **data) |
| |
|
These functions will operate on the first or last element of the list
|
| int32_t | no_os_list_add_first (struct no_os_list_desc *list_desc, void *data) |
| |
| int32_t | no_os_list_edit_first (struct no_os_list_desc *list_desc, void *new_data) |
| |
| int32_t | no_os_list_read_first (struct no_os_list_desc *list_desc, void **data) |
| |
| int32_t | no_os_list_get_first (struct no_os_list_desc *list_desc, void **data) |
| |
| int32_t | no_os_list_add_last (struct no_os_list_desc *list_desc, void *data) |
| |
| int32_t | no_os_list_edit_last (struct no_os_list_desc *list_desc, void *new_data) |
| |
| int32_t | no_os_list_read_last (struct no_os_list_desc *list_desc, void **data) |
| |
| int32_t | no_os_list_get_last (struct no_os_list_desc *list_desc, void **data) |
| |
|
These functions use an index to identify the element in the list.
|
| int32_t | no_os_list_add_idx (struct no_os_list_desc *list_desc, void *data, uint32_t idx) |
| |
| int32_t | no_os_list_edit_idx (struct no_os_list_desc *list_desc, void *new_data, uint32_t idx) |
| |
| int32_t | no_os_list_read_idx (struct no_os_list_desc *list_desc, void **data, uint32_t idx) |
| |
| int32_t | no_os_list_get_idx (struct no_os_list_desc *list_desc, void **data, uint32_t idx) |
| |
|
These functions use the specified f_cmp at no_os_list_init to identify the element this will operate on.
|
| int32_t | no_os_list_add_find (struct no_os_list_desc *list_desc, void *data) |
| |
| int32_t | no_os_list_edit_find (struct no_os_list_desc *list_desc, void *new_data, void *cmp_data) |
| |
| int32_t | no_os_list_read_find (struct no_os_list_desc *list_desc, void **data, void *cmp_data) |
| |
| int32_t | no_os_list_get_find (struct no_os_list_desc *list_desc, void **data, void *cmp_data) |
| |
List library header.
- Author
- Mihail Chindris (mihai.nosp@m.l.ch.nosp@m.indri.nosp@m.s@an.nosp@m.alog..nosp@m.com)
- Copyright
- Copyright 2020(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
Library description
This library handles double linked lists and it expose inseart, read, get and delete functions.
It also can be accesed using it member functions which wrapp function for usual list types.
Sample code
struct no_os_iterator *it;
uint32_t a;
printf("Last: %d\n", a);
printf("Current: %d\n", a);
printf("Last: %d\n", a);
int32_t no_os_iterator_read(struct no_os_iterator *iter, void **data)
int32_t no_os_list_add_last(struct no_os_list_desc *list_desc, void *data)
int32_t no_os_list_remove(struct no_os_list_desc *list_desc)
int32_t no_os_iterator_move(struct no_os_iterator *iter, int32_t steps)
int32_t no_os_iterator_remove(struct no_os_iterator *iter)
@ NO_OS_LIST_STACK
Definition no_os_list.h:182
@ NO_OS_LIST_DEFAULT
Definition no_os_list.h:162
int32_t no_os_list_read_last(struct no_os_list_desc *list_desc, void **data)
int32_t no_os_list_init(struct no_os_list_desc **list_desc, enum no_os_adapter_type type, f_cmp comparator)
int32_t no_os_iterator_init(struct no_os_iterator **iter, struct no_os_list_desc *list_desc, bool start)
Structure storing the list and function wrapper for usual list types.
Definition no_os_list.h:195
f_add push
Definition no_os_list.h:197
f_get pop
Definition no_os_list.h:199
#define NULL
Definition wrapper.h:67