166 return &builder->
dummy;
318 tommy_list_insert_head_not_empty(list, node);
320 tommy_list_insert_first(list, node);
336 tommy_list_insert_tail_not_empty(head, node);
338 tommy_list_insert_first(list, node);
355 if (head == reference) {
356 tommy_list_insert_head_not_empty(list, node);
360 reference->
prev = node;
363 node->
next = reference;
382 if (reference->
next == 0) {
383 tommy_list_insert_tail_not_empty(head, node);
386 node->
prev = reference;
391 reference->
next = node;
484 tommy_list_insert_head_not_empty(list, node);
575 if (second_head == 0)
580 if (first_head == 0) {
589 first_head->
prev = second_head->
prev;
590 second_head->
prev = first_tail;
593 first_tail->
next = second_head;
616 first_tail->
next = head;
617 head->
prev = first_tail;
775 void* data = node->
data;
795 void* data = node->
data;
Temporary list builder with an embedded sentinel.
Definition: tommylist.h:154
tommy_node dummy
Sentinel excluded from the resulting list.
Definition: tommylist.h:155
Data structure node.
Definition: tommytypes.h:242
struct tommy_node_struct * next
Next node.
Definition: tommytypes.h:247
struct tommy_node_struct * prev
Previous node.
Definition: tommytypes.h:253
void * data
Pointer to the element containing the node.
Definition: tommytypes.h:260
void * tommy_list_remove_tail(tommy_list *list)
Removes the element at the tail of the list.
Definition: tommylist.h:451
void tommy_list_insert_after(tommy_list *list, tommy_node *reference, tommy_node *node, void *data)
Inserts an element after the specified reference node.
Definition: tommylist.h:377
TOMMY_API void tommy_list_reverse(tommy_list *list)
Reverses the order of the elements in a list.
tommy_node * tommy_builder_concat(tommy_node *tail, tommy_node *head, tommy_node *last)
Appends a non-empty chain to a builder in O(1), preserving element order.
Definition: tommylist.h:178
void tommy_list_move_head(tommy_list *list, tommy_node *node)
Moves an existing node to the head of the list.
Definition: tommylist.h:478
void tommy_list_foreach_arg(tommy_list *list, tommy_foreach_arg_func *func, void *arg)
Calls the specified function with an argument for each element in the list.
Definition: tommylist.h:790
void tommy_list_split(tommy_list *list, tommy_node *node, tommy_list *second)
Splits a list before the specified node.
Definition: tommylist.h:518
tommy_size_t tommy_list_count(const tommy_list *list)
Gets the number of elements.
Definition: tommylist.h:722
TOMMY_API void tommy_list_merge(tommy_list *first, tommy_list *second, tommy_compare_func *cmp)
Merges two sorted lists.
void tommy_list_init(tommy_list *list)
Initializes the list.
Definition: tommylist.h:190
void tommy_list_swap(tommy_list *first, tommy_list *second)
Exchanges the contents of two lists.
Definition: tommylist.h:556
void tommy_list_insert_head(tommy_list *list, tommy_node *node, void *data)
Inserts an element at the head of a list.
Definition: tommylist.h:313
void tommy_list_prepend(tommy_list *first, tommy_list *second)
Prepends a list to another list.
Definition: tommylist.h:635
tommy_node * tommy_list
Doubly linked list type.
Definition: tommylist.h:146
tommy_node * tommy_list_prev(tommy_list *list, tommy_node *node)
Gets the previous node in the list.
Definition: tommylist.h:246
void * tommy_list_remove_existing(tommy_list *list, tommy_node *node)
Removes an element from the list.
Definition: tommylist.h:406
TOMMY_API void tommy_list_splice_after(tommy_list *list, tommy_node *reference, tommy_list *second)
Transfers all elements of a list after the specified reference node.
void tommy_list_clear(tommy_list *list)
Removes all elements.
Definition: tommylist.h:204
struct tommy_builder_struct tommy_builder
Temporary list builder with an embedded sentinel.
tommy_node * tommy_list_tail(tommy_list *list)
Gets the tail of the list.
Definition: tommylist.h:226
void tommy_list_insert_tail(tommy_list *list, tommy_node *node, void *data)
Inserts an element at the tail of a list.
Definition: tommylist.h:331
void tommy_list_concat(tommy_list *first, tommy_list *second)
Concatenates two lists.
Definition: tommylist.h:571
void tommy_list_insert_before(tommy_list *list, tommy_node *reference, tommy_node *node, void *data)
Inserts an element before the specified reference node.
Definition: tommylist.h:350
TOMMY_API void tommy_list_sort(tommy_list *list, tommy_compare_func *cmp)
Sorts a list.
void tommy_list_move_tail(tommy_list *list, tommy_node *node)
Moves an existing node to the tail of the list.
Definition: tommylist.h:494
tommy_node * tommy_builder_init(tommy_builder *builder)
Initializes an empty builder in O(1).
Definition: tommylist.h:163
void * tommy_list_remove_head(tommy_list *list)
Removes the element at the head of the list.
Definition: tommylist.h:430
tommy_node * tommy_list_head(tommy_list *list)
Gets the head of the list.
Definition: tommylist.h:215
TOMMY_API void tommy_list_splice_before(tommy_list *list, tommy_node *reference, tommy_list *second)
Transfers all elements of a list before the specified reference node.
tommy_bool_t tommy_list_empty(const tommy_list *list)
Checks whether the list is empty.
Definition: tommylist.h:711
void tommy_list_concat_builder(tommy_list *list, const tommy_builder *builder, tommy_node *tail)
Appends a builder's chain to a list, preserving element order and restoring list links.
Definition: tommylist.h:604
void tommy_list_foreach(tommy_list *list, tommy_foreach_func *func)
Calls the specified function for each element in the list.
Definition: tommylist.h:770
void tommy_foreach_func(void *elem)
Foreach function.
Definition: tommytypes.h:346
int tommy_compare_func(const void *elem_a, const void *elem_b)
Compare function for elements.
Definition: tommytypes.h:302
uint64_t tommy_size_t
Generic size_t type.
Definition: tommytypes.h:40
void tommy_foreach_arg_func(void *arg, void *elem)
Foreach function with an argument.
Definition: tommytypes.h:353
int tommy_bool_t
Generic boolean type.
Definition: tommytypes.h:53