55 #if !defined(__AMXC_LLIST_H__)
56 #define __AMXC_LLIST_H__
69 #define AMXC_LLIST_RANGE UINT32_MAX
238 #define amxc_llist_it_get_data(it, type, member) \
239 amxc_container_of(it, type, member)
253 #define amxc_llist_for_each(it, list) \
254 for(amxc_llist_it_t* it = amxc_llist_get_first(list), \
255 * it ## _next = amxc_llist_it_get_next(it); \
258 it ## _next = amxc_llist_it_get_next(it))
270 #define amxc_llist_iterate(it, list) \
271 for(amxc_llist_it_t* it = amxc_llist_get_first(list); \
273 it = amxc_llist_it_get_next(it))
287 #define amxc_llist_for_each_reverse(it, list) \
288 for(amxc_llist_it_t* it = amxc_llist_get_last(list), \
289 * it ## _prev = amxc_llist_it_get_previous(it); \
292 it ## _prev = amxc_llist_it_get_previous(it))
304 #define amxc_llist_iterate_reverse(it, list) \
305 for(amxc_llist_it_t* it = amxc_llist_get_last(list); \
307 it = amxc_llist_it_get_previous(it))
536 const unsigned int index);
562 const unsigned int index,
804 const unsigned int index) {
825 return reference != NULL ? reference->
next : NULL;
843 return reference != NULL ? reference->
prev : NULL;
858 return (
it != NULL &&
it->llist != NULL) ? true :
false;
int amxc_llist_it_init(amxc_llist_it_t *const it)
Initializes a linked list iterator.
AMXC_INLINE bool amxc_llist_it_is_in_list(const amxc_llist_it_t *const it)
Checks that an iterator is in a list.
AMXC_INLINE amxc_llist_it_t * amxc_llist_it_get_previous(const amxc_llist_it_t *const reference)
Gets the previous iterator in the list.
struct _amxc_llist_it amxc_llist_it_t
The linked list iterator structure.
int amxc_llist_it_insert_after(amxc_llist_it_t *const reference, amxc_llist_it_t *const it)
Inserts an iterator after another reference interator in the list.
int amxc_llist_it_insert_before(amxc_llist_it_t *const reference, amxc_llist_it_t *const it)
Inserts an iterator before a reference interator in the list.
AMXC_INLINE amxc_llist_it_t * amxc_llist_it_get_next(const amxc_llist_it_t *const reference)
Gets the next iterator in the list.
int(* amxc_llist_it_cmp_t)(amxc_llist_it_t *it1, amxc_llist_it_t *it2)
Type definition of a linked list iterator compare callback function.
void amxc_llist_it_clean(amxc_llist_it_t *const it, amxc_llist_it_delete_t func)
Removes the iterator from the list and frees allocated memory.
void amxc_llist_it_take(amxc_llist_it_t *const it)
Removes the iterator from the list.
unsigned int amxc_llist_it_index_of(const amxc_llist_it_t *const it)
Gets the index of an iterator in the list.
int amxc_llist_it_swap(amxc_llist_it_t *it1, amxc_llist_it_t *it2)
Swaps two linked list iterators.
int amxc_llist_move(amxc_llist_t *const dest, amxc_llist_t *const src)
Moves all items from one linked list to another linked list.
void amxc_llist_delete(amxc_llist_t **llist, amxc_llist_it_delete_t func)
Frees the previously allocated linked list.
AMXC_INLINE amxc_llist_it_t * amxc_llist_take_last(amxc_llist_t *const llist)
Removes the last item from the linked list.
AMXC_INLINE amxc_llist_it_t * amxc_llist_take_at(const amxc_llist_t *llist, const unsigned int index)
Removes an item at a certain position of the linked list.
size_t amxc_llist_size(const amxc_llist_t *const llist)
Calculates the size of the linked list.
int amxc_llist_new(amxc_llist_t **llist)
Allocates a linked list.
int amxc_llist_append(amxc_llist_t *const llist, amxc_llist_it_t *const it)
Adds an item to the end of the linked list.
int amxc_llist_init(amxc_llist_t *const llist)
Initializes a linked list.
int amxc_llist_sort(amxc_llist_t *const llist, amxc_llist_it_cmp_t cmp)
Sorts a linked list.
struct _amxc_llist amxc_llist_t
The linked list structure.
bool amxc_llist_is_empty(const amxc_llist_t *const llist)
Checks that the linked list is empty.
amxc_llist_it_t * amxc_llist_get_at(const amxc_llist_t *const llist, const unsigned int index)
Gets an item at a certain position of the linked list.
void amxc_llist_clean(amxc_llist_t *const llist, amxc_llist_it_delete_t func)
Removes all items from the linked list.
AMXC_INLINE amxc_llist_it_t * amxc_llist_take_first(amxc_llist_t *const llist)
Removes the first item from the linked list.
int amxc_llist_set_at(amxc_llist_t *llist, const unsigned int index, amxc_llist_it_t *const it)
Inserts an item at a certain position.
void(* amxc_llist_it_delete_t)(amxc_llist_it_t *it)
Definition of the linked list item delete function.
AMXC_INLINE amxc_llist_it_t * amxc_llist_get_last(const amxc_llist_t *const llist)
Gets the last item of the linked list.
int amxc_llist_prepend(amxc_llist_t *const llist, amxc_llist_it_t *const it)
Adds an item to the beginning of the linked list.
AMXC_INLINE amxc_llist_it_t * amxc_llist_get_first(const amxc_llist_t *const llist)
Gets the first item of the linked list.
The linked list iterator structure.
struct _amxc_llist_it * next
struct _amxc_llist * llist
struct _amxc_llist_it * prev
The linked list structure.
static amxc_htable_it_t it[2000]
static amxc_llist_t * llist
static amxc_llist_it_t it2
static amxc_llist_it_t it1