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

Go to the source code of this file.

Classes

struct  tagSRING

Defines

#define SRING_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 SRING_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 SRING_FOREACH_SAVE_END(loopvarname, loopvarnext, list)   }

Typedefs

typedef struct tagSRING SRING
typedef void(* SRING_VISITOR_V )(SRING *entry, void *context)
typedef int32_t(* SRING_VISITOR )(SRING *entry, void *context)
typedef int32_t(* SRING_COMPARE )(SRING *, SRING *)

Functions

M_INLINE void SRING_init (SRING *list)
 initialises an empty list head
M_INLINE int SRING_isempty (SRING *list)
 checks if argument list is empty
M_INLINE void SRING_insert_after (SRING *list, SRING *newentry)
 insert new entry after a given entry.
M_INLINE SRINGSRING_unlink_after (SRING *list)
M_INLINE void SRING_push_front (SRING *list, SRING *newentry)
M_INLINE SRINGSRING_pop_front (SRING *elem)
 remove the first element from list (used to maintain double ended queue)
M_INLINE SRINGSRING_get_first (SRING *list)
M_INLINE SRINGSRING_get_last (SRING *list)
M_INLINE SRINGSRING_get_next (SRING *end, SRING *cur)
M_INLINE size_t SRING_size (SRING *list)
M_INLINE SRINGSRING_get_nth (SRING *list, size_t nth)
M_INLINE SRINGSRING_get_nth_reverse (SRING *list, size_t nth)
M_INLINE void SRING_foreach (SRING *lst, SRING_VISITOR_V eval, void *context)
 iterate over all elements of a list, callback is invoked for either element of the list.
M_INLINE SRINGSRING_findif (SRING *lst, SRING_VISITOR eval, void *context, int32_t *retval)
 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 size_t SRING_deleteif (SRING *list, SRING_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 SRING_deleteall (SRING *list, SRING_VISITOR_V on_delete, void *context, int offset_of_link)
 iterate over all entries of the list and delete them.
M_INLINE void SRING_insert_sorted (SRING *list, SRING_COMPARE compare, SRING *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 SRING_reverse (SRING *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 size_t SRING_check (SRING *head)