3 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> STRUCTURE DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
6 /* Singly linked list node. */
9 struct _node_sl *next; /* Pointer to next node - NULL if last. */
10 void *val; /* Pointer to data value. */
13 typedef struct _node_sl node_sl;
15 /* Singly linked list. */
18 node_sl *first; /* Pointer to first node - NULL for empty list. */
21 typedef struct _list_sl list_sl;
23 /* Doubly linked list node. */
26 struct _node_dl *next; /* Pointer to next node - NULL if last. */
27 struct _node_dl *prev; /* Pointer to previous node - NULL if last. */
28 void *val; /* Pointer to data value. */
31 typedef struct _node_dl node_dl;
33 /* Doubly linked list. */
36 node_dl *first; /* Pointer to first node - NULL for empty list. */
37 node_dl *last; /* Pointer to last node - NULL for empty list. */
40 typedef struct _list_dl list_dl;
43 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> FUNCTION DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
46 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SINGLY LINLED LIST <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
49 /* Initialize a new singly linked list. */
50 void list_sl_new( list_sl **list_ppt );
52 /* Add a new node to the beginning of a singly linked list. */
53 void list_sl_add_beg( list_sl **list_ppt, node_sl **node_ppt );
55 /* Add a new node after a given node of a singly linked list. */
56 void list_sl_add_after( node_sl **node_ppt, node_sl **new_node_ppt );
58 /* Remove the first node of a singly linked list. */
59 void list_sl_remove_beg( list_sl **list_ppt );
61 /* Remove the node next to this one in a singly linked list. */
62 void list_sl_remove_after( node_sl **node_ppt );
64 /* Debug function to print all elements from a singly linked list. */
65 void list_sl_print( list_sl *list_pt );
67 /* Free memory for all nodes in and including the singly linked list. */
68 void list_sl_destroy( list_sl **list_ppt );
71 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DOUBLY LINKED LIST <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
74 /* Initialize a new doubly linked list. */
75 void list_dl_new( list_dl **list_ppt );
77 /* Add a new node to the beginning of a doubly linked list. */
78 void list_dl_add_beg( list_dl **list_ppt, node_dl **node_ppt );
80 /* Add a new node to the end of a doubly linked list. */
81 void list_dl_add_end( list_dl **list_ppt, node_dl **node_ppt );
83 /* Add a new node before a given node of a doubly linked list. */
84 void list_dl_add_before( list_dl **list_ppt, node_dl **node_ppt, node_dl **new_node_ppt );
86 /* Add a new node after a given node of a doubly linked list. */
87 void list_dl_add_after( list_dl **list_ppt, node_dl **node_ppt, node_dl **new_node_ppt );
89 /* Remove a node from a doubly linked list. */
90 void list_dl_remove( list_dl **list_ppt, node_dl **node_ppt );
92 /* Debug function to print all elements from a doubly linked list. */
93 void list_dl_print( list_dl *list_pt );
95 /* Free memory for all nodes in and including the doubly linked list. */
96 void list_dl_destroy( list_dl **list_ppt );
99 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/