/* Manipulate doubly linked lists. Copyright (C) 2025 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef _DOUBLY_LINKED_LIST_H #define _DOUBLY_LINKED_LIST_H /* Doubly linked list implementation enforcing typing. This implementation of doubly linked list tries to achieve the enforcement of typing similarly to C++ templates, but without encapsulation. All the functions are prefixed with the type of the value: "AType_xxx". Some functions are prefixed with "_AType_xxx" and are not part of the public API, so should not be used, except for _##LTYPE##_merge_sort with a caveat (see note above its definition). Each function (### is a placeholder for method name) has a macro for: (1) its invocation LINKED_LIST_###(LTYPE). (2) its prototype LINKED_LIST_DECL_###(A, A2, scope). To add in a header file, or a source file for forward declaration. 'scope' should be set respectively to 'extern', or 'static'. (3) its definition LINKED_LIST_DEFN_###(A, A2, scope). To add in a source file with the 'scope' set respectively to nothing, or 'static' depending on (2). Data structures requirements: - LTYPE corresponds to the node of a doubly linked list. It needs to define attributes 'prev' and 'next' which are pointers on the type of a node. For instance: struct my_list_node { T value; struct my_list_node *prev; struct my_list_node *next; }; - LWRAPPERTYPE is a structure wrapping the nodes and others metadata (first, last, size). */