List library header. More...
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
Classes | |
struct | no_os_list_desc |
Structure storing the list and function wrapper for usual list types. More... | |
Typedefs | |
typedef int32_t(* | f_cmp) (void *data1, void *data2) |
Prototype of the compare function. | |
Generic functions | |
Each function interacting with the list have one of the following formats. | |
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. | |
Enumerations | |
enum | no_os_adapter_type { NO_OS_LIST_DEFAULT , NO_OS_LIST_QUEUE , NO_OS_LIST_STACK , NO_OS_LIST_PRIORITY_LIST } |
Selects functionalities for functions in no_os_list_desc. More... | |
Functions | |
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) |
Iterator functions | |
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) |
Operations on the ends of the list | |
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) |
Operations by index | |
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) |
Operations by comparation | |
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.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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.
typedef int32_t(* f_add) (struct no_os_list_desc *list_desc, void *data) |
Add an element in the list.
The element of the list is created and the data field is stored in it.
list_desc | - Reference to the list. Created by no_os_list_init. |
data | - Data to store in a list element |
typedef int32_t(* f_cmp) (void *data1, void *data2) |
Prototype of the compare function.
The function used to compare the elements of the liste when doing operations on an ordered list.
data1 | - First element to be compared |
data2 | - Second element to be compared |
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.
list_desc | - Reference to the list. Created by no_os_list_init. |
new_data | - New data to replace the old one |
typedef int32_t(* f_get) (struct no_os_list_desc *list_desc, void **data) |
Read and remove an element from the list.
list_desc | - Reference to the list. Created by no_os_list_init. |
data | - Content of the list element, NULL if some error occur. |
typedef int32_t(* f_read) (struct no_os_list_desc *list_desc, void **data) |
Read an element from the list.
list_desc | - Reference to the list. Created by no_os_list_init. |
data | - Content of the list element, NULL if some error occur. |
enum no_os_adapter_type |
Selects functionalities for functions in no_os_list_desc.
Enumerator | |
---|---|
NO_OS_LIST_DEFAULT | Default type is NO_OS_LIST_STACK |
NO_OS_LIST_QUEUE | Functions for a FIFO list (First-in first-out). Elements are inserted in one end and extracted from the other end.
|
NO_OS_LIST_STACK | Functions for a LIFO list (Last-in first-out). Elements are inserted and extracted only from the same end.
|
NO_OS_LIST_PRIORITY_LIST | Functions for ordered list. The order of element is determinated usinge the f_cmp.
|
int32_t no_os_iterator_edit | ( | struct no_os_iterator * | iter, |
void * | new_data ) |
int32_t no_os_iterator_find | ( | struct no_os_iterator * | iter, |
void * | cmp_data ) |
int32_t no_os_iterator_get | ( | struct no_os_iterator * | iter, |
void ** | data ) |
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_insert | ( | struct no_os_iterator * | iter, |
void * | data, | ||
bool | after ) |
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_read | ( | struct no_os_iterator * | iter, |
void ** | data ) |
int32_t no_os_iterator_remove | ( | struct no_os_iterator * | iter | ) |
int32_t no_os_list_add_find | ( | struct no_os_list_desc * | list_desc, |
void * | data ) |
int32_t no_os_list_add_first | ( | struct no_os_list_desc * | list_desc, |
void * | data ) |
int32_t no_os_list_add_idx | ( | struct no_os_list_desc * | list_desc, |
void * | data, | ||
uint32_t | idx ) |
int32_t no_os_list_add_last | ( | 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_edit_first | ( | struct no_os_list_desc * | list_desc, |
void * | new_data ) |
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_edit_last | ( | struct no_os_list_desc * | list_desc, |
void * | new_data ) |
int32_t no_os_list_get_find | ( | struct no_os_list_desc * | list_desc, |
void ** | data, | ||
void * | cmp_data ) |
int32_t no_os_list_get_first | ( | struct no_os_list_desc * | list_desc, |
void ** | data ) |
int32_t no_os_list_get_idx | ( | struct no_os_list_desc * | list_desc, |
void ** | data, | ||
uint32_t | idx ) |
int32_t no_os_list_get_last | ( | struct no_os_list_desc * | list_desc, |
void ** | data ) |
int32_t no_os_list_get_size | ( | struct no_os_list_desc * | list_desc, |
uint32_t * | out_size ) |
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_read_find | ( | struct no_os_list_desc * | list_desc, |
void ** | data, | ||
void * | cmp_data ) |
int32_t no_os_list_read_first | ( | struct no_os_list_desc * | list_desc, |
void ** | data ) |
int32_t no_os_list_read_idx | ( | struct no_os_list_desc * | list_desc, |
void ** | data, | ||
uint32_t | idx ) |
int32_t no_os_list_read_last | ( | struct no_os_list_desc * | list_desc, |
void ** | data ) |
int32_t no_os_list_remove | ( | struct no_os_list_desc * | list_desc | ) |