C Container Collection (CCC)
Loading...
Searching...
No Matches
doubly_linked_list.h
Go to the documentation of this file.
1
44#ifndef CCC_DOUBLY_LINKED_LIST_H
45#define CCC_DOUBLY_LINKED_LIST_H
46
48#include <stddef.h>
52#include "types.h" /* IWYU pragma: export */
53
65
75
91#define CCC_doubly_linked_list_default(type_name, type_intruder_field) \
92 CCC_private_doubly_linked_list_for(type_name, type_intruder_field)
93
103#define CCC_doubly_linked_list_for(type_name, type_intruder_field) \
104 CCC_private_doubly_linked_list_for(type_name, type_intruder_field)
105
119#define CCC_doubly_linked_list_from( \
120 type_intruder_field, allocator, destructor, compound_literal_array... \
121) \
122 CCC_private_doubly_linked_list_from( \
123 type_intruder_field, allocator, destructor, compound_literal_array \
124 )
125
146#define CCC_doubly_linked_list_emplace_back( \
147 list_pointer, allocator_pointer, type_compound_literal... \
148) \
149 CCC_private_doubly_linked_list_emplace_back( \
150 list_pointer, allocator_pointer, type_compound_literal \
151 )
152
167#define CCC_doubly_linked_list_emplace_front( \
168 list_pointer, allocator_pointer, type_compound_literal... \
169) \
170 CCC_private_doubly_linked_list_emplace_front( \
171 list_pointer, allocator_pointer, type_compound_literal \
172 )
173
182 CCC_Doubly_linked_list_node *type_intruder,
183 CCC_Allocator const *allocator
184);
185
194 CCC_Doubly_linked_list_node *type_intruder,
195 CCC_Allocator const *allocator
196);
197
208 CCC_Doubly_linked_list_node *position_node,
209 CCC_Doubly_linked_list_node *type_intruder,
210 CCC_Allocator const *allocator
211);
212
219 CCC_Doubly_linked_list *list, CCC_Allocator const *allocator
220);
221
228 CCC_Doubly_linked_list *list, CCC_Allocator const *allocator
229);
230
241);
242
252 CCC_Doubly_linked_list_node *type_intruder,
253 CCC_Allocator const *allocator
254);
255
275 CCC_Doubly_linked_list_node *type_intruder_begin,
276 CCC_Doubly_linked_list_node *type_intruder_end,
277 CCC_Allocator const *allocator
278);
279
296 CCC_Doubly_linked_list_node *type_intruder_begin,
297 CCC_Doubly_linked_list_node *type_intruder_end
298);
299
308 CCC_Doubly_linked_list *position_doubly_linked_list,
309 CCC_Doubly_linked_list_node *type_intruder_position,
310 CCC_Doubly_linked_list *to_cut_doubly_linked_list,
311 CCC_Doubly_linked_list_node *type_intruder_to_cut
312);
313
325 CCC_Doubly_linked_list *position_doubly_linked_list,
326 CCC_Doubly_linked_list_node *type_intruder_position,
327 CCC_Doubly_linked_list *to_cut_doubly_linked_list,
328 CCC_Doubly_linked_list_node *type_intruder_to_cut_begin,
329 CCC_Doubly_linked_list_node *type_intruder_to_cut_exclusive_end
330);
331
359 CCC_Doubly_linked_list *doubly_linked_list,
360 CCC_Doubly_linked_list_node *type_intruder,
361 CCC_Order order,
362 CCC_Comparator const *comparator,
363 CCC_Allocator const *allocator
364);
365
380 CCC_Doubly_linked_list const *doubly_linked_list,
381 CCC_Order order,
382 CCC_Comparator const *comparator
383);
384
411 CCC_Destructor const *destructor,
412 CCC_Allocator const *allocator
413);
414
424[[nodiscard]] void *
426
430[[nodiscard]] void *
432
439[[nodiscard]] void *CCC_doubly_linked_list_next(
440 CCC_Doubly_linked_list const *list,
441 CCC_Doubly_linked_list_node const *type_intruder
442);
443
451 CCC_Doubly_linked_list const *list,
452 CCC_Doubly_linked_list_node const *type_intruder
453);
454
458[[nodiscard]] void *
460
464[[nodiscard]] void *
466
476[[nodiscard]] void *
478
482[[nodiscard]] void *
484
490[[nodiscard]] CCC_Doubly_linked_list_node *
492
496[[nodiscard]] CCC_Count
498
502[[nodiscard]] CCC_Tribool
504
508[[nodiscard]] CCC_Tribool
510
516#ifdef DOUBLY_LINKED_LIST_USING_NAMESPACE_CCC
517/* NOLINTBEGIN(readability-identifier-naming) */
518typedef CCC_Doubly_linked_list_node Doubly_linked_list_node;
519typedef CCC_Doubly_linked_list Doubly_linked_list;
520# define doubly_linked_list_default(arguments...) \
521 CCC_doubly_linked_list_default(arguments)
522# define doubly_linked_list_for(arguments...) \
523 CCC_doubly_linked_list_for(arguments)
524# define doubly_linked_list_from(arguments...) \
525 CCC_doubly_linked_list_from(arguments)
526# define doubly_linked_list_emplace_back(arguments...) \
527 CCC_doubly_linked_list_emplace_back(arguments)
528# define doubly_linked_list_emplace_front(arguments...) \
529 CCC_doubly_linked_list_emplace_front(arguments)
530# define doubly_linked_list_push_front(arguments...) \
531 CCC_doubly_linked_list_push_front(arguments)
532# define doubly_linked_list_push_back(arguments...) \
533 CCC_doubly_linked_list_push_back(arguments)
534# define doubly_linked_list_front(arguments...) \
535 CCC_doubly_linked_list_front(arguments)
536# define doubly_linked_list_back(arguments...) \
537 CCC_doubly_linked_list_back(arguments)
538# define doubly_linked_list_pop_front(arguments...) \
539 CCC_doubly_linked_list_pop_front(arguments)
540# define doubly_linked_list_pop_back(arguments...) \
541 CCC_doubly_linked_list_pop_back(arguments)
542# define doubly_linked_list_extract(arguments...) \
543 CCC_doubly_linked_list_extract(arguments)
544# define doubly_linked_list_extract_range(arguments...) \
545 CCC_doubly_linked_list_extract_range(arguments)
546# define doubly_linked_list_erase(arguments...) \
547 CCC_doubly_linked_list_erase(arguments)
548# define doubly_linked_list_erase_range(arguments...) \
549 CCC_doubly_linked_list_erase_range(arguments)
550# define doubly_linked_list_splice(arguments...) \
551 CCC_doubly_linked_list_splice(arguments)
552# define doubly_linked_list_splice_range(arguments...) \
553 CCC_doubly_linked_list_splice_range(arguments)
554# define doubly_linked_list_sort(arguments...) \
555 CCC_doubly_linked_list_sort(arguments)
556# define doubly_linked_list_insert_sorted(arguments...) \
557 CCC_doubly_linked_list_insert_sorted(arguments)
558# define doubly_linked_list_is_sorted(arguments...) \
559 CCC_doubly_linked_list_is_sorted(arguments)
560# define doubly_linked_list_begin(arguments...) \
561 CCC_doubly_linked_list_begin(arguments)
562# define doubly_linked_list_next(arguments...) \
563 CCC_doubly_linked_list_next(arguments)
564# define doubly_linked_list_reverse_begin(arguments...) \
565 CCC_doubly_linked_list_reverse_begin(arguments)
566# define doubly_linked_list_reverse_next(arguments...) \
567 CCC_doubly_linked_list_reverse_next(arguments)
568# define doubly_linked_list_end(arguments...) \
569 CCC_doubly_linked_list_end(arguments)
570# define doubly_linked_list_reverse_end(arguments...) \
571 CCC_doubly_linked_list_reverse_end(arguments)
572# define doubly_linked_list_node_begin(arguments...) \
573 CCC_doubly_linked_list_node_begin(arguments)
574# define doubly_linked_list_count(arguments...) \
575 CCC_doubly_linked_list_count(arguments)
576# define doubly_linked_list_is_empty(arguments...) \
577 CCC_doubly_linked_list_is_empty(arguments)
578# define doubly_linked_list_clear(arguments...) \
579 CCC_doubly_linked_list_clear(arguments)
580# define doubly_linked_list_validate(arguments...) \
581 CCC_doubly_linked_list_validate(arguments)
582/* NOLINTEND(readability-identifier-naming) */
583#endif /* DOUBLY_LINKED_LIST_USING_NAMESPACE_CCC */
584
585#endif /* CCC_LIST_H */
CCC_Result CCC_doubly_linked_list_pop_back(CCC_Doubly_linked_list *list, CCC_Allocator const *allocator)
Pop the user type at the back of the list. O(1).
void * CCC_doubly_linked_list_next(CCC_Doubly_linked_list const *list, CCC_Doubly_linked_list_node const *type_intruder)
Return the user type following the element known to be in the list. O(1).
void * CCC_doubly_linked_list_insert_sorted(CCC_Doubly_linked_list *doubly_linked_list, CCC_Doubly_linked_list_node *type_intruder, CCC_Order order, CCC_Comparator const *comparator, CCC_Allocator const *allocator)
Inserts type_intruder in sorted position according to the non-decreasing order of the list determined...
void * CCC_doubly_linked_list_push_front(CCC_Doubly_linked_list *list, CCC_Doubly_linked_list_node *type_intruder, CCC_Allocator const *allocator)
Push user type wrapping type_intruder to the front of the list. O(1).
void * CCC_doubly_linked_list_erase(CCC_Doubly_linked_list *list, CCC_Doubly_linked_list_node *type_intruder, CCC_Allocator const *allocator)
Returns the element following an erased element from the list. O(1).
CCC_Result CCC_doubly_linked_list_splice(CCC_Doubly_linked_list *position_doubly_linked_list, CCC_Doubly_linked_list_node *type_intruder_position, CCC_Doubly_linked_list *to_cut_doubly_linked_list, CCC_Doubly_linked_list_node *type_intruder_to_cut)
Repositions to_cut before pos. Only list pointers are modified. O(1).
CCC_Count CCC_doubly_linked_list_count(CCC_Doubly_linked_list const *list)
Return the count of elements in the list. O(N).
void * CCC_doubly_linked_list_extract(CCC_Doubly_linked_list *list, CCC_Doubly_linked_list_node *type_intruder)
Returns the element following an extracted element from the list without deallocating regardless of a...
void * CCC_doubly_linked_list_insert(CCC_Doubly_linked_list *list, CCC_Doubly_linked_list_node *position_node, CCC_Doubly_linked_list_node *type_intruder, CCC_Allocator const *allocator)
Insert user type wrapping type_intruder before position_node. O(1).
CCC_Tribool CCC_doubly_linked_list_validate(CCC_Doubly_linked_list const *list)
Validates internal state of the list.
void * CCC_doubly_linked_list_push_back(CCC_Doubly_linked_list *list, CCC_Doubly_linked_list_node *type_intruder, CCC_Allocator const *allocator)
Push user type wrapping type_intruder to the back of the list. O(1).
CCC_Result CCC_doubly_linked_list_splice_range(CCC_Doubly_linked_list *position_doubly_linked_list, CCC_Doubly_linked_list_node *type_intruder_position, CCC_Doubly_linked_list *to_cut_doubly_linked_list, CCC_Doubly_linked_list_node *type_intruder_to_cut_begin, CCC_Doubly_linked_list_node *type_intruder_to_cut_exclusive_end)
Splices the list to cut before the specified position. The range being cut is exclusive from [start,...
CCC_Doubly_linked_list_node * CCC_doubly_linked_list_node_begin(CCC_Doubly_linked_list const *list)
Return a handle to the list element at the front of the list which may be the sentinel....
void * CCC_doubly_linked_list_end(CCC_Doubly_linked_list const *list)
Return the end sentinel with no accessible fields. O(1).
void * CCC_doubly_linked_list_reverse_end(CCC_Doubly_linked_list const *list)
Return the start sentinel with no accessible fields. O(1).
void * CCC_doubly_linked_list_begin(CCC_Doubly_linked_list const *list)
Return the user type at the start of the list or NULL if empty. O(1).
void * CCC_doubly_linked_list_reverse_next(CCC_Doubly_linked_list const *list, CCC_Doubly_linked_list_node const *type_intruder)
Return the user type following the element known to be in the list moving from back to front....
CCC_Tribool CCC_doubly_linked_list_is_empty(CCC_Doubly_linked_list const *list)
Return if the size of the list is equal to 0. O(1).
CCC_Result CCC_doubly_linked_list_pop_front(CCC_Doubly_linked_list *list, CCC_Allocator const *allocator)
Pop the user type at the front of the list. O(1).
void * CCC_doubly_linked_list_extract_range(CCC_Doubly_linked_list *list, CCC_Doubly_linked_list_node *type_intruder_begin, CCC_Doubly_linked_list_node *type_intruder_end)
Returns the element following an extracted range of elements from the list without deallocating regar...
void * CCC_doubly_linked_list_erase_range(CCC_Doubly_linked_list *list, CCC_Doubly_linked_list_node *type_intruder_begin, CCC_Doubly_linked_list_node *type_intruder_end, CCC_Allocator const *allocator)
Returns the element following an extracted range of elements from the list. O(N).
void * CCC_doubly_linked_list_front(CCC_Doubly_linked_list const *list)
Returns the user type at the front of the list. O(1).
void * CCC_doubly_linked_list_back(CCC_Doubly_linked_list const *list)
Returns the user type at the back of the list. O(1).
void * CCC_doubly_linked_list_reverse_begin(CCC_Doubly_linked_list const *list)
Return the user type at the end of the list or NULL if empty. O(1).
CCC_Result CCC_doubly_linked_list_clear(CCC_Doubly_linked_list *list, CCC_Destructor const *destructor, CCC_Allocator const *allocator)
Clear the contents of the list freeing elements, if given allocation permission. O(N).
CCC_Tribool CCC_doubly_linked_list_is_sorted(CCC_Doubly_linked_list const *doubly_linked_list, CCC_Order order, CCC_Comparator const *comparator)
Returns true if the list is sorted in non-decreasing order according to the user provided comparison ...
The Private Doubly Linked List Types and Interface.
The type passed by reference to any container function that may need to allocate memory....
Definition: types.h:384
The type passed by reference to any container function that may need to compare elements....
Definition: types.h:424
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:243
The type passed by reference to any container function that may need to destroy elements....
Definition: types.h:472
Definition: private_doubly_linked_list.h:39
Definition: private_doubly_linked_list.h:73
The C Container Collection Fundamental Types.
CCC_Order
A three-way comparison for comparison functions.
Definition: types.h:213
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:178
CCC_Result
A result of actions on containers.
Definition: types.h:192