|
Simple data structures / objects in plain C Snapshot
|
#include <cutils/base.h>Go to the source code of this file.
Classes | |
| struct | tagDLIST_entry |
| struct | DLIST |
Defines | |
| #define | DLIST_FOREACH(loopvarname, list) |
| Macro for iterate over all elements of a list, the list is traversed in forward direction from first element to the last element. | |
| #define | DLIST_FOREACH_REVERSE(loopvarname, list) |
| Macro for iterate over all elements of a list, the list is traversed in reverse direction from last element to the first element. | |
| #define | DLIST_FOREACH_SAVE(loopvarname, loopvarnext, list) |
| Macro for iterate over all elements of a list, You may delete the current element; the list is traversed in forward direction from first element to the last element. | |
| #define | DLIST_FOREACH_REVERSE_SAVE(loopvarname, loopvarnext, list) |
| Macro for iterate over all elements of a list, You may delete the current element; the list is traversed in reverse direction from last element to the first element. | |
Typedefs | |
| typedef struct tagDLIST_entry | DLIST_entry |
| typedef void(* | DLIST_VISITOR_V )(DLIST *list, DLIST_entry *entry, void *context) |
| typedef int32_t(* | DLIST_VISITOR )(DLIST *list, DLIST_entry *entry, void *context) |
| typedef int32_t(* | DLIST_COMPARE )(DLIST_entry *, DLIST_entry *) |
Functions | |
| M_INLINE void | DLIST_init (DLIST *head) |
| initialises an empty list head | |
| M_INLINE int | DLIST_isempty (DLIST *head) |
| checks if argument list is empty | |
| M_INLINE int | DLIST_insert_before (DLIST *list, DLIST_entry *pos, DLIST_entry *newentry) |
| insert new entry before a given entry. | |
| M_INLINE void | DLIST_insert_after (DLIST *list, DLIST_entry *pos, DLIST_entry *newentry) |
| insert new entry after a given entry. | |
| M_INLINE DLIST_entry * | DLIST_unlink (DLIST *list, DLIST_entry *link) |
| delete an element from a list. | |
| M_INLINE void | DLIST_push_back (DLIST *list, DLIST_entry *newentry) |
| insert element as last in list (used to maintain queue) | |
| M_INLINE void | DLIST_push_front (DLIST *list, DLIST_entry *newentry) |
| insert element as first in list (used to maintain queue) | |
| M_INLINE DLIST_entry * | DLIST_pop_front (DLIST *list) |
| remove the first element from list (used to maintain double ended queue) | |
| M_INLINE DLIST_entry * | DLIST_pop_back (DLIST *list) |
| remove the last element from list (used to maintain double ended queue) | |
| M_INLINE DLIST_entry * | DLIST_get_first (DLIST *list) |
| M_INLINE DLIST_entry * | DLIST_get_last (DLIST *list) |
| M_INLINE DLIST_entry * | DLIST_get_next (DLIST_entry *cur) |
| M_INLINE DLIST_entry * | DLIST_get_prev (DLIST_entry *cur) |
| M_INLINE size_t | DLIST_size (DLIST *list) |
| M_INLINE DLIST_entry * | DLIST_get_nth (DLIST *list, size_t nth) |
| M_INLINE DLIST_entry * | DLIST_get_nth_reverse (DLIST *list, size_t nth) |
| M_INLINE void | DLIST_foreach (DLIST *lst, DLIST_VISITOR_V eval, void *context, int save_from_del) |
| iterate over all elements of a list, callback is invoked for either element of the list. list is traversed from first element to the last element. | |
| M_INLINE void | DLIST_foreach_reverse (DLIST *lst, DLIST_VISITOR_V eval, void *context, int save_from_delete) |
| iterate over all elements of a list, callback is invoked for either element of the list. list is traversed backword from last element to the first element. | |
| M_INLINE DLIST_entry * | DLIST_findif (DLIST *lst, DLIST_VISITOR eval, void *context, int32_t *retval, int save_from_del) |
| find an element within the linked list. callback is invoked for each element of the list, in forward direction from first element to last element; when the callback returns non zero value the iteration stops as we have found what we searched for. | |
| M_INLINE DLIST_entry * | DLIST_findif_reverse (DLIST *lst, DLIST_VISITOR eval, void *context, int32_t *retval, int save_from_delete) |
| find an element within the linked list. callback is invoked for each element of the list, in reverse direction from last element to first element; when the callback returns non zero value the iteration stops as we have found what we searched for. | |
| M_INLINE void | DLIST_deleteif (DLIST *list, DLIST_VISITOR check_if, void *context, int offset_of_link) |
| iterate over all entries of the list and delete entries that match predicate from the list, and frees the memory (optionally) | |
| M_INLINE void | DLIST_deleteall (DLIST *list, DLIST_VISITOR_V on_delete, void *context, int offset_of_link) |
| iterate over all entries of the list and delete them. | |
| M_INLINE void | DLIST_insert_sorted (DLIST *list, DLIST_COMPARE compare, DLIST_entry *newentry) |
| insert new element into sorted list; Maintains ordering relationship between elements of linked list (sort by ascending order) A sorting algorithm based on this function is not very efficient; it is of complexity O(n^2); nevertheless usefull if a list is modified and has to be always maintained in sorted order. | |
| M_INLINE void | DLIST_reverse (DLIST *lst) |
| Reverse a list This function turns the first element into the last element, the second element into the one before the last, and so on and on. | |
| M_INLINE int | DLIST_check (DLIST *header) |
| check consistency of list | |
1.7.4