25#ifndef CCC_DOUBLY_LINKED_LIST_H
26#define CCC_DOUBLY_LINKED_LIST_H
32#include "impl/impl_doubly_linked_list.h"
77#define ccc_dll_init(list_name, struct_name, list_elem_field, alloc_fn, \
79 ccc_impl_dll_init(list_name, struct_name, list_elem_field, alloc_fn, \
101#define ccc_dll_emplace_back(list_ptr, type_initializer...) \
102 ccc_impl_dll_emplace_back(list_ptr, type_initializer)
117#define ccc_dll_emplace_front(list_ptr, type_initializer...) \
118 ccc_impl_dll_emplace_front(list_ptr, type_initializer)
357#ifdef DOUBLY_LINKED_LIST_USING_NAMESPACE_CCC
360# define dll_init(args...) ccc_dll_init(args)
361# define dll_emplace_back(args...) ccc_dll_emplace_back(args)
362# define dll_emplace_front(args...) ccc_dll_emplace_front(args)
363# define dll_push_front(args...) ccc_dll_push_front(args)
364# define dll_push_back(args...) ccc_dll_push_back(args)
365# define dll_front(args...) ccc_dll_front(args)
366# define dll_back(args...) ccc_dll_back(args)
367# define dll_pop_front(args...) ccc_dll_pop_front(args)
368# define dll_pop_back(args...) ccc_dll_pop_back(args)
369# define dll_extract(args...) ccc_dll_extract(args)
370# define dll_extract_range(args...) ccc_dll_extract_range(args)
371# define dll_erase(args...) ccc_dll_erase(args)
372# define dll_erase_range(args...) ccc_dll_erase_range(args)
373# define dll_splice(args...) ccc_dll_splice(args)
374# define dll_splice_range(args...) ccc_dll_splice_range(args)
375# define dll_begin(args...) ccc_dll_begin(args)
376# define dll_next(args...) ccc_dll_next(args)
377# define dll_rbegin(args...) ccc_dll_rbegin(args)
378# define dll_rnext(args...) ccc_dll_rnext(args)
379# define dll_end(args...) ccc_dll_end(args)
380# define dll_end_elem(args...) ccc_dll_end_elem(args)
381# define dll_rend(args...) ccc_dll_rend(args)
382# define dll_begin_elem(args...) ccc_dll_begin_elem(args)
383# define dll_end_elem(args...) ccc_dll_end_elem(args)
384# define dll_end_sentinel(args...) ccc_dll_end_sentinel(args)
385# define dll_size(args...) ccc_dll_size(args)
386# define dll_is_empty(args...) ccc_dll_is_empty(args)
387# define dll_clear(args...) ccc_dll_clear(args)
388# define dll_validate(args...) ccc_dll_validate(args)
bool ccc_dll_validate(ccc_doubly_linked_list const *l)
Validates internal state of the list.
ccc_dll_elem * ccc_dll_begin_elem(ccc_doubly_linked_list const *l)
Return a handle to the list element at the front of the list which may be the sentinel....
void * ccc_dll_rnext(ccc_doubly_linked_list const *l, ccc_dll_elem const *elem)
Return the user type following the element known to be in the list moving from back to front....
void * ccc_dll_erase(ccc_doubly_linked_list *l, ccc_dll_elem *elem)
Returns the element following an erased element from the list. O(1).
void * ccc_dll_extract_range(ccc_doubly_linked_list *l, ccc_dll_elem *elem_begin, ccc_dll_elem *elem_end)
Returns the element following an extracted range of elements from the list without deallocating regar...
ccc_result ccc_dll_splice(ccc_doubly_linked_list *pos_sll, ccc_dll_elem *pos, ccc_doubly_linked_list *to_cut_sll, ccc_dll_elem *to_cut)
Repositions to_cut before pos. Only list pointers are modified. O(1).
void * ccc_dll_push_back(ccc_doubly_linked_list *l, ccc_dll_elem *elem)
Push user type wrapping elem to the back of the list. O(1).
ccc_result ccc_dll_pop_back(ccc_doubly_linked_list *l)
Pop the user type at the back of the list. O(1).
ccc_result ccc_dll_splice_range(ccc_doubly_linked_list *pos_sll, ccc_dll_elem *pos, ccc_doubly_linked_list *to_cut_sll, ccc_dll_elem *begin, ccc_dll_elem *end)
Repositions begin to end before pos. Only list pointers are modified O(N).
bool ccc_dll_is_empty(ccc_doubly_linked_list const *l)
Return if the size of the list is equal to 0. O(1).
void * ccc_dll_extract(ccc_doubly_linked_list *l, ccc_dll_elem *elem)
Returns the element following an extracted element from the list without deallocating regardless of a...
ccc_dll_elem * ccc_dll_end_elem(ccc_doubly_linked_list const *l)
Return a handle to the list element at the back of the list which may be the sentinel....
void * ccc_dll_front(ccc_doubly_linked_list const *l)
Returns the user type at the front of the list. O(1).
ccc_dll_elem * ccc_dll_end_sentinel(ccc_doubly_linked_list const *l)
Return a handle to the sentinel at the back of the list. O(1).
void * ccc_dll_begin(ccc_doubly_linked_list const *l)
Return the user type at the start of the list or NULL if empty. O(1).
ccc_result ccc_dll_pop_front(ccc_doubly_linked_list *l)
Pop the user type at the front of the list. O(1).
void * ccc_dll_next(ccc_doubly_linked_list const *l, ccc_dll_elem const *elem)
Return the user type following the element known to be in the list. O(1).
struct ccc_dll_ ccc_doubly_linked_list
A container offering bidirectional, insert, removal, and iteration.
Definition: doubly_linked_list.h:45
void * ccc_dll_rbegin(ccc_doubly_linked_list const *l)
Return the user type at the end of the list or NULL if empty. O(1).
void * ccc_dll_back(ccc_doubly_linked_list const *l)
Returns the user type at the back of the list. O(1).
void * ccc_dll_push_front(ccc_doubly_linked_list *l, ccc_dll_elem *elem)
Push user type wrapping elem to the front of the list. O(1).
void * ccc_dll_rend(ccc_doubly_linked_list const *l)
Return the start sentinel with no accessible fields. O(1).
void * ccc_dll_erase_range(ccc_doubly_linked_list *l, ccc_dll_elem *elem_begin, ccc_dll_elem *elem_end)
Returns the element following an extracted range of elements from the list. O(N).
struct ccc_dll_elem_ ccc_dll_elem
A doubly linked list intrusive element to embedded in a user type.
Definition: doubly_linked_list.h:55
ccc_result ccc_dll_clear(ccc_doubly_linked_list *l, ccc_destructor_fn *fn)
Clear the contents of the list freeing elements, if given allocation permission. O(N).
void * ccc_dll_end(ccc_doubly_linked_list const *l)
Return the end sentinel with no accessible fields. O(1).
void * ccc_dll_insert(ccc_doubly_linked_list *l, ccc_dll_elem *pos_elem, ccc_dll_elem *elem)
Insert user type wrapping elem before pos_elem. O(1).
size_t ccc_dll_size(ccc_doubly_linked_list const *l)
Return the size of the list. O(1).
The C Container Collection Fundamental Types.
ccc_result
A result of actions on containers.
Definition: types.h:65
void ccc_destructor_fn(ccc_user_type)
A callback function for destroying an element in the container.
Definition: types.h:234