aboutsummaryrefslogtreecommitdiff
path: root/src/linked_list.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/linked_list.h62
1 files changed, 25 insertions, 37 deletions
diff --git a/src/linked_list.h b/src/linked_list.h
index 8a075b5..be5f6ab 100644
--- a/src/linked_list.h
+++ b/src/linked_list.h
@@ -9,26 +9,39 @@
#define LINKED_LIST_H
/**
- * @struct LinkedList
- * @brief A doubly-linked list container.
- * @details Maintains references to the first and last nodes in the list,
- * as well as the current number of elements.
- */
-typedef struct LinkedList LinkedList;
-
-/**
* @struct LinkedListNode
* @brief A node within a doubly-linked list.
* @details Each node contains pointers to the next and previous nodes,
* allowing bidirectional traversal, and a generic data pointer.
*/
-typedef struct LinkedListNode LinkedListNode;
+typedef struct LinkedListNode {
+ /**
+ * @brief Pointer to the next node in the list.
+ * @details NULL if this is the last node.
+ */
+ LinkedListNode *next;
+
+ /**
+ * @brief Pointer to the previous node in the list.
+ * @details NULL if this is the first node (head).
+ */
+ LinkedListNode *prev;
+
+ /**
+ * @brief Generic pointer to the node's data.
+ * @details The caller is responsible for managing the memory
+ * pointed to by this pointer.
+ */
+ void *data;
+} LinkedListNode;
/**
* @struct LinkedList
- * @brief A doubly-linked list container structure.
+ * @brief A doubly-linked list container.
+ * @details Maintains references to the first and last nodes in the list,
+ * as well as the current number of elements.
*/
-struct LinkedList {
+typedef struct LinkedList {
/**
* @brief Pointer to the first node in the list.
* @details NULL if the list is empty.
@@ -46,32 +59,7 @@ struct LinkedList {
* @details Updated whenever nodes are added or removed.
*/
int size;
-};
-
-/**
- * @struct LinkedListNode
- * @brief A single node in a doubly-linked list structure.
- */
-struct LinkedListNode {
- /**
- * @brief Pointer to the next node in the list.
- * @details NULL if this is the last node.
- */
- LinkedListNode *next;
-
- /**
- * @brief Pointer to the previous node in the list.
- * @details NULL if this is the first node (head).
- */
- LinkedListNode *prev;
-
- /**
- * @brief Generic pointer to the node's data.
- * @details The caller is responsible for managing the memory
- * pointed to by this pointer.
- */
- void *data;
-};
+} LinkedList;
/**
* @brief Allocates and initializes an empty linked list.