C Container Collection (CCC)
Loading...
Searching...
No Matches
singly_linked_list.h
Go to the documentation of this file.
1
42#ifndef CCC_SINGLY_LINKED_LIST_H
43#define CCC_SINGLY_LINKED_LIST_H
44
46#include <stddef.h>
49#include "private/private_singly_linked_list.h"
50#include "types.h"
51
62
72
90#define CCC_singly_linked_list_initialize(struct_name, type_intruder_field, \
91 compare, allocate, context_data) \
92 CCC_private_singly_linked_list_initialize( \
93 struct_name, type_intruder_field, compare, allocate, context_data)
94
109#define CCC_singly_linked_list_from(type_intruder_field, compare, allocate, \
110 destroy, context_data, \
111 compound_literal_array...) \
112 CCC_private_singly_linked_list_from(type_intruder_field, compare, \
113 allocate, destroy, context_data, \
114 compound_literal_array)
115
131[[nodiscard]] void *
133 CCC_Singly_linked_list_node *type_intruder);
134
146#define CCC_singly_linked_list_emplace_front(list_pointer, \
147 type_compound_literal...) \
148 CCC_private_singly_linked_list_emplace_front(list_pointer, \
149 type_compound_literal)
150
156
170 CCC_Singly_linked_list *position_list,
171 CCC_Singly_linked_list_node *type_intruder_position,
172 CCC_Singly_linked_list *splice_list,
173 CCC_Singly_linked_list_node *type_intruder_splice);
174
192 CCC_Singly_linked_list *position_list,
193 CCC_Singly_linked_list_node *type_intruder_position,
194 CCC_Singly_linked_list *to_cut_list,
195 CCC_Singly_linked_list_node *type_intruder_to_cut_begin,
196 CCC_Singly_linked_list_node *type_intruder_to_cut_exclusive_end);
197
211 CCC_Singly_linked_list_node *type_intruder);
212
226 CCC_Singly_linked_list_node *type_intruder_begin,
227 CCC_Singly_linked_list_node *type_intruder_end);
228
237void *
239 CCC_Singly_linked_list_node *type_intruder);
240
253 CCC_Singly_linked_list_node *type_intruder_begin,
254 CCC_Singly_linked_list_node *type_intruder_end);
255
268
282
294
315 CCC_Type_destructor *destroy);
316
327[[nodiscard]] void *
329
334[[nodiscard]] CCC_Singly_linked_list_node *
336
341[[nodiscard]] CCC_Singly_linked_list_node *
343
349[[nodiscard]] void *
351
358[[nodiscard]] void *
360 CCC_Singly_linked_list_node const *type_intruder);
361
372[[nodiscard]] void *
374
378[[nodiscard]] CCC_Count
380
385[[nodiscard]] CCC_Tribool
387
392[[nodiscard]] CCC_Tribool
394
399#ifdef SINGLY_LINKED_LIST_USING_NAMESPACE_CCC
400typedef CCC_Singly_linked_list_node singly_linked_list_node;
401typedef CCC_Singly_linked_list Singly_linked_list;
402# define singly_linked_list_initialize(args...) \
403 CCC_singly_linked_list_initialize(args)
404# define singly_linked_list_from(args...) CCC_singly_linked_list_from(args)
405# define singly_linked_list_emplace_front(args...) \
406 CCC_singly_linked_list_emplace_front(args)
407# define singly_linked_list_push_front(args...) \
408 CCC_singly_linked_list_push_front(args)
409# define singly_linked_list_front(args...) CCC_singly_linked_list_front(args)
410# define singly_linked_list_pop_front(args...) \
411 CCC_singly_linked_list_pop_front(args)
412# define singly_linked_list_splice(args...) \
413 CCC_singly_linked_list_splice(args)
414# define singly_linked_list_splice_range(args...) \
415 CCC_singly_linked_list_splice_range(args)
416# define singly_linked_list_extract(args...) \
417 CCC_singly_linked_list_extract(args)
418# define singly_linked_list_extract_range(args...) \
419 CCC_singly_linked_list_extract_range(args)
420# define singly_linked_list_erase(args...) CCC_singly_linked_list_erase(args)
421# define singly_linked_list_erase_range(args...) \
422 CCC_singly_linked_list_erase_range(args)
423# define singly_linked_list_sort(args...) CCC_singly_linked_list_sort(args)
424# define singly_linked_list_insert_sorted(args...) \
425 CCC_singly_linked_list_insert_sorted(args)
426# define singly_linked_list_is_sorted(args...) \
427 CCC_singly_linked_list_is_sorted(args)
428# define singly_linked_list_begin(args...) CCC_singly_linked_list_begin(args)
429# define singly_linked_list_node_begin(args...) \
430 CCC_singly_linked_list_node_begin(args)
431# define singly_linked_list_node_before_begin(args...) \
432 CCC_singly_linked_list_node_before_begin(args)
433# define singly_linked_list_end(args...) CCC_singly_linked_list_end(args)
434# define singly_linked_list_next(args...) CCC_singly_linked_list_next(args)
435# define singly_linked_list_count(args...) CCC_singly_linked_list_count(args)
436# define singly_linked_list_is_empty(args...) \
437 CCC_singly_linked_list_is_empty(args)
438# define singly_linked_list_validate(args...) \
439 CCC_singly_linked_list_validate(args)
440# define singly_linked_list_clear(args...) CCC_singly_linked_list_clear(args)
441#endif /* SINGLY_LINKED_LIST_USING_NAMESPACE_CCC */
442
443#endif /* CCC_FORWARD_LIST_H */
void * CCC_singly_linked_list_next(CCC_Singly_linked_list const *list, CCC_Singly_linked_list_node const *type_intruder)
Return the user type following type_intruder in the list. O(1).
void * CCC_singly_linked_list_extract(CCC_Singly_linked_list *list, CCC_Singly_linked_list_node *type_intruder)
Extracts an element from the list without freeing it. O(N).
CCC_Result CCC_singly_linked_list_clear(CCC_Singly_linked_list *list, CCC_Type_destructor *destroy)
Clears the list freeing memory if needed. O(N).
CCC_Tribool CCC_singly_linked_list_is_empty(CCC_Singly_linked_list const *list)
Return true if the list is empty. O(1).
void * CCC_singly_linked_list_begin(CCC_Singly_linked_list const *list)
Return the user type at the front of the list. O(1).
void * CCC_singly_linked_list_erase(CCC_Singly_linked_list *list, CCC_Singly_linked_list_node *type_intruder)
Erases type_intruder from the list returning the following element. O(N).
CCC_Result CCC_singly_linked_list_sort(CCC_Singly_linked_list *list)
Sorts the singly linked list in non-decreasing order as defined by the provided comparison function....
CCC_Count CCC_singly_linked_list_count(CCC_Singly_linked_list const *list)
Return the count of nodes in the list. O(1).
void * CCC_singly_linked_list_extract_range(CCC_Singly_linked_list *list, CCC_Singly_linked_list_node *type_intruder_begin, CCC_Singly_linked_list_node *type_intruder_end)
Extracts a range of elements from the list without freeing them. O(N).
void * CCC_singly_linked_list_front(CCC_Singly_linked_list const *list)
Return a pointer to the element at the front of the list. O(1).
void * CCC_singly_linked_list_push_front(CCC_Singly_linked_list *list, CCC_Singly_linked_list_node *type_intruder)
Push the type wrapping type_intruder to the front of the list. O(1).
CCC_Singly_linked_list_node * CCC_singly_linked_list_node_before_begin(CCC_Singly_linked_list const *list)
Return the list node type before the starting node. O(1).
CCC_Result CCC_singly_linked_list_splice_range(CCC_Singly_linked_list *position_list, CCC_Singly_linked_list_node *type_intruder_position, CCC_Singly_linked_list *to_cut_list, CCC_Singly_linked_list_node *type_intruder_to_cut_begin, CCC_Singly_linked_list_node *type_intruder_to_cut_exclusive_end)
Inserts the [begin, end) of spliced elements after the provided position. O(N).
CCC_Tribool CCC_singly_linked_list_is_sorted(CCC_Singly_linked_list const *list)
Returns true if the list is sorted in non-decreasing order according to the user provided comparison ...
CCC_Result CCC_singly_linked_list_pop_front(CCC_Singly_linked_list *list)
Pop the front element from the list. O(1).
void * CCC_singly_linked_list_erase_range(CCC_Singly_linked_list *list, CCC_Singly_linked_list_node *type_intruder_begin, CCC_Singly_linked_list_node *type_intruder_end)
Erases a range from the list returning the element after end. O(N).
void * CCC_singly_linked_list_end(CCC_Singly_linked_list const *list)
Return the sentinel at the end of the list. Do not access sentinel. O(1).
CCC_Result CCC_singly_linked_list_splice(CCC_Singly_linked_list *position_list, CCC_Singly_linked_list_node *type_intruder_position, CCC_Singly_linked_list *splice_list, CCC_Singly_linked_list_node *type_intruder_splice)
Inserts splice element after the provided position. O(N).
void * CCC_singly_linked_list_insert_sorted(CCC_Singly_linked_list *list, CCC_Singly_linked_list_node *type_intruder)
Inserts e in sorted position according to the non-decreasing order of the list determined by the user...
CCC_Singly_linked_list_node * CCC_singly_linked_list_node_begin(CCC_Singly_linked_list const *list)
Return the list node type at the front of the list. O(1).
CCC_Tribool CCC_singly_linked_list_validate(CCC_Singly_linked_list const *list)
Returns true if the invariants of the list hold.
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:202
Definition: private_singly_linked_list.h:33
Definition: private_singly_linked_list.h:66
The C Container Collection Fundamental Types.
CCC_Tribool
A three state boolean to allow for an error state. Error is -1, False is 0, and True is 1.
Definition: types.h:133
void CCC_Type_destructor(CCC_Type_context)
A callback function for destroying an element in the container.
Definition: types.h:376
CCC_Result
A result of actions on containers.
Definition: types.h:148