00001
00013 #ifndef _CO_LIST_H_
00014 #define _CO_LIST_H_
00015
00027
00028
00029
00030
00031 #include "co_int.h"
00032 #include "co_bool.h"
00033
00034 #include <stddef.h>
00035
00036
00037 #include "rwnx_config.h"
00038
00039
00040 #include "compiler.h"
00041
00042
00043
00044
00045
00046
00048 struct co_list_hdr
00049 {
00051 struct co_list_hdr *next;
00052 };
00053
00055 struct co_list
00056 {
00058 struct co_list_hdr *first;
00060 struct co_list_hdr *last;
00061 };
00062
00063
00064
00065
00066
00067
00074 void co_list_init(struct co_list *list);
00075
00087 void co_list_pool_init(struct co_list *list,
00088 void *pool,
00089 size_t elmt_size,
00090 uint32_t elmt_cnt,
00091 void *default_value);
00092
00101 void co_list_push_back(struct co_list *list,
00102 struct co_list_hdr *list_hdr);
00103
00112 void co_list_push_front(struct co_list *list,
00113 struct co_list_hdr *list_hdr);
00123 struct co_list_hdr *co_list_pop_front(struct co_list *list);
00124
00136 void co_list_extract(struct co_list *list,
00137 struct co_list_hdr *list_hdr);
00138
00149 bool co_list_find(struct co_list *list,
00150 struct co_list_hdr *list_hdr);
00151
00167 void co_list_insert(struct co_list * const list,
00168 struct co_list_hdr * const element,
00169 bool (*cmp)(struct co_list_hdr const *elementA,
00170 struct co_list_hdr const *elementB));
00171
00186 void co_list_insert_after(struct co_list * const list,
00187 struct co_list_hdr * const prev_element,
00188 struct co_list_hdr * const element);
00189
00204 void co_list_insert_before(struct co_list * const list,
00205 struct co_list_hdr * const next_element,
00206 struct co_list_hdr * const element);
00207
00218 void co_list_concat(struct co_list *list1, struct co_list *list2);
00219
00234 void co_list_remove(struct co_list *list,
00235 struct co_list_hdr *prev_element,
00236 struct co_list_hdr *element);
00246 __INLINE bool co_list_is_empty(const struct co_list *const list)
00247 {
00248 bool listempty;
00249 listempty = (list->first == NULL);
00250 return (listempty);
00251 }
00252
00262 uint32_t co_list_cnt(const struct co_list *const list);
00263
00273 __INLINE struct co_list_hdr *co_list_pick(const struct co_list *const list)
00274 {
00275 return(list->first);
00276 }
00277
00287 __INLINE struct co_list_hdr *co_list_pick_last(const struct co_list *const list)
00288 {
00289 return(list->last);
00290 }
00291
00301 __INLINE struct co_list_hdr *co_list_next(const struct co_list_hdr *const list_hdr)
00302 {
00303 return(list_hdr->next);
00304 }
00305
00306
00308
00309 #endif // _CO_LIST_H_