no-OS
list.h
Go to the documentation of this file.
1 /***************************************************************************/
90 #ifndef LIST_H
91 #define LIST_H
92 
93 /******************************************************************************/
94 /***************************** Include Files **********************************/
95 /******************************************************************************/
96 
97 #include <stdint.h>
98 #include <stdbool.h>
99 
100 /******************************************************************************/
101 /*************************** Types Declarations *******************************/
102 /******************************************************************************/
103 
116 struct list_desc;
117 
122 struct iterator;
123 
136 typedef int32_t (*f_cmp)(void *data1, void *data2);
137 
157 typedef int32_t (*f_add)(struct list_desc *list_desc, void *data);
158 
167 typedef int32_t (*f_edit)(struct list_desc *list_desc, void *new_data);
168 
180 typedef int32_t (*f_read)(struct list_desc *list_desc, void **data);
181 
191 typedef int32_t (*f_get)(struct list_desc *list_desc, void **data);
192 
232 };
233 
234 struct list_desc {
246  void *priv_desc;
247 };
248 
249 /******************************************************************************/
250 /************************ Functions Declarations ******************************/
251 /******************************************************************************/
252 
253 int32_t list_init(struct list_desc **list_desc, enum adapter_type type,
254  f_cmp comparator);
255 int32_t list_remove(struct list_desc *list_desc);
256 int32_t list_get_size(struct list_desc *list_desc, uint32_t *out_size);
257 
264 int32_t iterator_init(struct iterator **iter, struct list_desc *list_desc,
265  bool start);
266 int32_t iterator_remove(struct iterator *iter);
267 int32_t iterator_move(struct iterator *iter, int32_t steps);
268 int32_t iterator_move_to_idx(struct iterator *iter, int32_t idx);
269 int32_t iterator_find(struct iterator *iter, void *cmp_data);
270 int32_t iterator_insert(struct iterator *iter, void *data, bool after);
271 int32_t iterator_edit(struct iterator *iter, void *new_data);
272 int32_t iterator_read(struct iterator *iter, void **data);
273 int32_t iterator_get(struct iterator *iter, void **data);
281 int32_t list_add_first(struct list_desc *list_desc, void *data);
282 int32_t list_edit_first(struct list_desc *list_desc, void *new_data);
283 int32_t list_read_first(struct list_desc *list_desc, void **data);
284 int32_t list_get_first(struct list_desc *list_desc, void **data);
285 
286 int32_t list_add_last(struct list_desc *list_desc, void *data);
287 int32_t list_edit_last(struct list_desc *list_desc, void *new_data);
288 int32_t list_read_last(struct list_desc *list_desc, void **data);
289 int32_t list_get_last(struct list_desc *list_desc, void **data);
297 int32_t list_add_idx(struct list_desc *list_desc, void *data, uint32_t idx);
298 int32_t list_edit_idx(struct list_desc *list_desc, void *new_data,
299  uint32_t idx);
300 int32_t list_read_idx(struct list_desc *list_desc, void **data, uint32_t idx);
301 int32_t list_get_idx(struct list_desc *list_desc, void **data, uint32_t idx);
310 int32_t list_add_find(struct list_desc *list_desc, void *data);
311 int32_t list_edit_find(struct list_desc *list_desc, void *new_data,
312  void *cmp_data);
313 int32_t list_read_find(struct list_desc *list_desc, void **data,
314  void *cmp_data);
315 int32_t list_get_find(struct list_desc *list_desc, void **data, void *cmp_data);
318 #endif //LIST_H
iterator_insert
int32_t iterator_insert(struct iterator *iter, void *data, bool after)
list_desc::swap
f_edit swap
Definition: list.h:244
iterator_find
int32_t iterator_find(struct iterator *iter, void *cmp_data)
list_read_idx
int32_t list_read_idx(struct list_desc *list_desc, void **data, uint32_t idx)
f_cmp
int32_t(* f_cmp)(void *data1, void *data2)
Prototype of the compare function.
Definition: list.h:136
LIST_PRIORITY_LIST
@ LIST_PRIORITY_LIST
Definition: list.h:231
list_desc::top_next
f_read top_next
Definition: list.h:240
LIST_DEFAULT
@ LIST_DEFAULT
Definition: list.h:201
list_desc::push
f_add push
Definition: list.h:236
list_edit_first
int32_t list_edit_first(struct list_desc *list_desc, void *new_data)
list_get_find
int32_t list_get_find(struct list_desc *list_desc, void **data, void *cmp_data)
list_add_last
int32_t list_add_last(struct list_desc *list_desc, void *data)
list_edit_idx
int32_t list_edit_idx(struct list_desc *list_desc, void *new_data, uint32_t idx)
iterator_init
int32_t iterator_init(struct iterator **iter, struct list_desc *list_desc, bool start)
list_get_last
int32_t list_get_last(struct list_desc *list_desc, void **data)
f_read
int32_t(* f_read)(struct list_desc *list_desc, void **data)
Read an element from the list.
Definition: list.h:180
adapter_type
adapter_type
Selects functionalities for functions in list_desc.
Definition: list.h:199
list_desc::priv_desc
void * priv_desc
Definition: list.h:246
LIST_STACK
@ LIST_STACK
Definition: list.h:221
LIST_QUEUE
@ LIST_QUEUE
Definition: list.h:211
iterator_read
int32_t iterator_read(struct iterator *iter, void **data)
list_get_idx
int32_t list_get_idx(struct list_desc *list_desc, void **data, uint32_t idx)
list_init
int32_t list_init(struct list_desc **list_desc, enum adapter_type type, f_cmp comparator)
list_add_first
int32_t list_add_first(struct list_desc *list_desc, void *data)
list_desc
Structure storing the list and function wrapper for usual list types.
Definition: list.h:234
list_add_find
int32_t list_add_find(struct list_desc *list_desc, void *data)
list_desc::pop
f_get pop
Definition: list.h:238
f_get
int32_t(* f_get)(struct list_desc *list_desc, void **data)
Read and remove an element from the list.
Definition: list.h:191
f_add
int32_t(* f_add)(struct list_desc *list_desc, void *data)
Add an element in the list.
Definition: list.h:157
iterator_remove
int32_t iterator_remove(struct iterator *iter)
iterator_move
int32_t iterator_move(struct iterator *iter, int32_t steps)
f_edit
int32_t(* f_edit)(struct list_desc *list_desc, void *new_data)
Edit an element in the list. The content is replaced by new_data.
Definition: list.h:167
list_read_last
int32_t list_read_last(struct list_desc *list_desc, void **data)
list_read_first
int32_t list_read_first(struct list_desc *list_desc, void **data)
list_edit_last
int32_t list_edit_last(struct list_desc *list_desc, void *new_data)
list_read_find
int32_t list_read_find(struct list_desc *list_desc, void **data, void *cmp_data)
list_desc::back
f_read back
Definition: list.h:242
iterator_edit
int32_t iterator_edit(struct iterator *iter, void *new_data)
list_get_size
int32_t list_get_size(struct list_desc *list_desc, uint32_t *out_size)
list_remove
int32_t list_remove(struct list_desc *list_desc)
iterator_get
int32_t iterator_get(struct iterator *iter, void **data)
list_add_idx
int32_t list_add_idx(struct list_desc *list_desc, void *data, uint32_t idx)
list_edit_find
int32_t list_edit_find(struct list_desc *list_desc, void *new_data, void *cmp_data)
list_get_first
int32_t list_get_first(struct list_desc *list_desc, void **data)
iterator_move_to_idx
int32_t iterator_move_to_idx(struct iterator *iter, int32_t idx)