9 typedef char list_base_t
; // allowed to use char* to access any type of mem.
10 typedef uint8_t list_index_t
;
13 LIST_BASE_T
* buffer
; // buffer
14 LIST_INDEX_T first
; // position of first element
15 LIST_INDEX_T end
; // position of last element +1
16 LIST_INDEX_T ct
; // number of elements in the list
17 const LIST_INDEX_T sz
; // size of the buffer
20 #define LIST_DEF(buff) {\
21 .buffer = (buff), .first = 0, .last = 0, .ct = 0,\
22 .sz = sizeof(buff) / sizeof(list_base_t) \
25 // add to front (push)
26 #define list_push list_push_front
27 int8_t list_push_front(list_t
*list
, list_base_t x
);
28 int8_t list_push_front_o(list_t
*list
, list_base_t x
);
30 // add to back (append)
31 #define list_append list_push_back
32 list_error_t
list_push_back(list_t
*list
, list_base_t x
);
33 list_error_t
list_push_back_o(list_t
*list
, list_base_t x
);
36 #define list_pop list_pop_front
37 list_base_t
list_pop_front(list_t
*list
); // (pop)
38 #define list_take list_pop_back
39 list_base_t
list_pop_back(list_t
*list
); // (take)
42 list_base_t
list_peek_front(list_t
*list
);
43 list_base_t
list_peek_back(list_t
*list
);
44 list_base_t
list_peek(list_t
*list
, list_index_t index
);
46 void list_flush(list_t
*list
);
47 bool list_empty(list_t
*list
);
48 bool list_full(list_t
*list
);