Simple data structures / objects in plain C Snapshot
Classes | Defines | Typedefs | Functions
dring.h File Reference
#include <cutils/base.h>

Go to the source code of this file.

Classes

struct  tagDRING

Defines

#define DRING_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 DRING_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 DRING_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 DRING_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 tagDRING DRING
typedef void(* DRING_VISITOR_V )(DRING *entry, void *context)
typedef int32_t(* DRING_VISITOR )(DRING *entry, void *context)
typedef int32_t(* DRING_COMPARE )(DRING *, DRING *)

Functions

M_INLINE void DRING_init (DRING *head)
 initialises an empty list head
M_INLINE int DRING_isempty (DRING *list)
 checks if argument list is empty
M_INLINE void DRING_insert_before (DRING *list, DRING *newentry)
 insert new entry before a given entry.
M_INLINE void DRING_insert_after (DRING *list, DRING *newentry)
 insert new entry after a given entry.
void DRING_insert_sorted (DRING *list, DRING_COMPARE compare, DRING *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 DRINGDRING_unlink (DRING *list)
 delete an element from a list.
M_INLINE void DRING_push_back (DRING *list, DRING *newentry)
 insert element as last in list (used to maintain double ended queue)
M_INLINE void DRING_push_front (DRING *list, DRING *newentry)
 insert element as first in list (used to maintain double ended queue)
M_INLINE DRINGDRING_pop_front (DRING *elem)
 remove first element from list (used to maintain double ended queue)
M_INLINE DRINGDRING_pop_back (DRING *elem)
 remove last element from list (used to maintain double ended queue)
M_INLINE DRINGDRING_get_first (DRING *list)
M_INLINE DRINGDRING_get_last (DRING *list)
M_INLINE DRINGDRING_get_next (DRING *end, DRING *cur)
M_INLINE DRINGDRING_get_prev (DRING *end, DRING *cur)
M_INLINE size_t DRING_size (DRING *list)
M_INLINE DRINGDRING_get_nth (DRING *list, size_t nth)
M_INLINE DRINGDRING_get_nth_reverse (DRING *list, size_t nth)
void DRING_foreach (DRING *lst, DRING_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 forward from first element to the last element.
void DRING_foreach_reverse (DRING *lst, DRING_VISITOR_V eval, void *context, int save_from_delete)
 iterate over all elements of a list, callback is invoked for each element of the list. list is traversed backword from last element to the first element.
M_INLINE DRINGDRING_findif (DRING *lst, DRING_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 DRINGDRING_find_reverse (DRING *lst, DRING_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 size_t DRING_deleteif (DRING *list, DRING_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 DRING_deleteall (DRING *list, DRING_VISITOR_V on_delete, void *context, int offset_of_link)
 iterate over all entries of the list and delete them.
M_INLINE void DRING_reverse (DRING *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 DRING_check (DRING *header)
 check consistency of list