78#define CSTL_DLIST_INITIALIZER(NAME, TYPE, MEMB) \
85 .off = offsetof(TYPE, MEMB), \
97#define DECLARE_CSTL_DLIST(NAME, TYPE, MEMB) \
98 struct cstl_dlist NAME = \
99 CSTL_DLIST_INITIALIZER(NAME, TYPE, MEMB)
109 struct cstl_dlist *
const l,
const size_t off)
void cstl_xtor_func_t(void *obj, void *priv)
Type for functions called to construct, clear, or destroy an object.
int cstl_visit_func_t(void *obj, void *priv)
Type for visit callbacks from objects supporting foreach.
int cstl_compare_func_t(const void *obj1, const void *obj2, void *priv)
Function type for comparing (in)equality of two objects.
static void cstl_dlist_init(struct cstl_dlist *const l, const size_t off)
Initialize a list object.
void * cstl_dlist_front(struct cstl_dlist *l)
Get a pointer to the first object in the list.
void cstl_dlist_reverse(struct cstl_dlist *l)
Reverse the order of items in the list.
void cstl_dlist_clear(struct cstl_dlist *l, cstl_xtor_func_t *clr)
Remove objects from and reinitialize a list.
void * cstl_dlist_pop_front(struct cstl_dlist *l)
Remove the first item in the list and return it.
void cstl_dlist_erase(struct cstl_dlist *l, void *obj)
Remove an object from the list.
static size_t cstl_dlist_size(const struct cstl_dlist *const l)
Get the number of objects in the list.
void cstl_dlist_swap(struct cstl_dlist *a, struct cstl_dlist *b)
Swap the list objects at the two given locations.
void cstl_dlist_concat(struct cstl_dlist *list, struct cstl_dlist *more)
Append one list to the end of another.
void * cstl_dlist_find(const struct cstl_dlist *l, const void *obj, cstl_compare_func_t *cmp, void *priv, cstl_dlist_foreach_dir_t dir)
Perform a linear search for an object.
void * cstl_dlist_pop_back(struct cstl_dlist *l)
Remove the last item in the list and return it.
void cstl_dlist_push_front(struct cstl_dlist *l, void *obj)
Insert a new object at the front of the list.
cstl_dlist_foreach_dir_t
The direction in which to traverse the list during cstl_dlist_foreach()
void cstl_dlist_push_back(struct cstl_dlist *l, void *obj)
Insert a new object at the back of the list.
int cstl_dlist_foreach(struct cstl_dlist *l, cstl_visit_func_t *visit, void *priv, cstl_dlist_foreach_dir_t dir)
Call a user-supplied function for each object in a list.
void * cstl_dlist_back(struct cstl_dlist *l)
Get a pointer to the last object in the list.
void cstl_dlist_sort(struct cstl_dlist *l, cstl_compare_func_t *cmp, void *priv)
Sort the items in a list.
void cstl_dlist_insert(struct cstl_dlist *l, void *before, void *obj)
Insert a new object into the list.
@ CSTL_DLIST_FOREACH_DIR_FWD
Traverse the list from front to back.
@ CSTL_DLIST_FOREACH_DIR_REV
Traverse the list from back to front.
Node to anchor an element within a list.