34 printf (
"%d\n", llist_is_empty (&node1));
35 printf (
"%d\n", llist_is_empty (&node2));
45 llist_insert_next (&list, &node1);
46 printf (
"%d\n", llist_is_empty (&list));
47 printf (
"%d\n", llist_is_empty (&node1));
48 printf (
"%d\n", llist_is_single (&node1));
49 llist_insert_next (&node1, &node2);
50 printf (
"%d\n", llist_is_single (&node1));
51 llist_insert_prev (&node1, &node3);
52 printf (
"%d\n", llist_next (&list) == &node3);
53 printf (
"%d\n", llist_next (&node3) == &node1);
54 printf (
"%d\n", llist_next (&node1) == &node2);
55 printf (
"%d\n", llist_prev (&list) == &node2);
56 printf (
"%d\n", llist_count (&list));
68 llist_insert_tail (&list, &node2);
69 llist_insert_tail (&list, &node3);
70 llist_insert_tail (&list, &node4);
71 llist_insert_head (&list, &node1);
73 printf (
"%d\n", llist_is_head (&list, &node1));
74 printf (
"%d\n", llist_is_tail (&list, &node4));
75 printf (
"%d\n", llist_is_head (&list, &node4));
76 printf (
"%d\n", llist_is_tail (&list, &node1));
77 printf (
"%d\n", llist_is_end (&list, &list));
78 printf (
"%d\n", llist_is_member (&list, &node3));
79 printf (
"%d\n", llist_is_member (&list, &nil));
81 printf (
"%d\n", llist_is_before_after (&list, &node1, &node3));
82 printf (
"%d\n", llist_is_before_after (&list, &node3, &node1));
83 printf (
"%d\n", llist_is_before_after (&list, &node1, &nil));
95 llist_insert_tail (&list, &node2);
96 llist_insert_tail (&list, &node3);
97 llist_insert_tail (&list, &node4);
98 llist_insert_head (&list, &node1);
102 if(itr == &node1) printf (
"node1 ");
103 else if(itr == &node2) printf (
"node2 ");
104 else if(itr == &node3) printf (
"node3 ");
105 else if(itr == &node4) printf (
"node4 ");
106 else printf (
"unknown ");
111 llist_unlink (&node2);
112 llist_unlink (&node3);
116 if(itr == &node1) printf (
"node1 ");
117 else if(itr == &node2) printf (
"node2 ");
118 else if(itr == &node3) printf (
"node3 ");
119 else if(itr == &node4) printf (
"node4 ");
120 else printf (
"unknown ");
123 printf (
"%d\n", llist_is_empty (&node2));
124 printf (
"%d\n", llist_is_empty (&node3));
125 printf (
"%d\n", llist_is_empty (&nil));
137 llist_insert_tail (&list, &node2);
138 llist_insert_tail (&list, &node3);
139 llist_insert_tail (&list, &node4);
140 llist_insert_head (&list, &node1);
144 if(itr == &node1) printf (
"node1 ");
145 else if(itr == &node2) printf (
"node2 ");
146 else if(itr == &node3) printf (
"node3 ");
147 else if(itr == &node4) printf (
"node4 ");
148 else printf (
"unknown ");
157 if(itr == &node1) printf (
"node1 ");
158 else if(itr == &node2) printf (
"node2 ");
159 else if(itr == &node3) printf (
"node3 ");
160 else if(itr == &node4) printf (
"node4 ");
161 else printf (
"unknown ");
165 llist_insert_tail (&list, &node2);
166 llist_insert_tail (&list, &node3);
167 llist_insert_tail (&list, &node4);
168 llist_insert_head (&list, &node1);
175 if(itr == &node1) printf (
"node1 ");
176 else if(itr == &node2) printf (
"node2 ");
177 else if(itr == &node3) printf (
"node3 ");
178 else if(itr == &node4) printf (
"node4 ");
179 else printf (
"unknown ");
188 llist_init (&source);
191 llist_init (&something);
193 llist_insert_head (&source, &something);
195 llist target = {NULL,NULL};
199 llist_relocate (&target);
200 CHECK (llist_is_head (&target, &something));
Helpers and support macros for defining test executables in C.
#define LLIST_AUTO(name)
Macro to instantiate a local llist.
#define LLIST_FOREACH_REV(list, node)
Iterate backward over a list.
#define LLIST_FOREACH(list, node)
Iterate forward over a list.
Intrusive cyclic double linked list There is only one node type which contains a forward and a backwa...
#define LLIST_WHILE_TAIL(list, tail)
Consume a list from tail.
#define LLIST_WHILE_HEAD(list, head)
Consume a list from head.