43 printf (
"%d\n", llist_is_empty (&node1));
44 printf (
"%d\n", llist_is_empty (&node2));
54 llist_insert_next (&list, &node1);
55 printf (
"%d\n", llist_is_empty (&list));
56 printf (
"%d\n", llist_is_empty (&node1));
57 printf (
"%d\n", llist_is_single (&node1));
58 llist_insert_next (&node1, &node2);
59 printf (
"%d\n", llist_is_single (&node1));
60 llist_insert_prev (&node1, &node3);
61 printf (
"%d\n", llist_next (&list) == &node3);
62 printf (
"%d\n", llist_next (&node3) == &node1);
63 printf (
"%d\n", llist_next (&node1) == &node2);
64 printf (
"%d\n", llist_prev (&list) == &node2);
65 printf (
"%d\n", llist_count (&list));
77 llist_insert_tail (&list, &node2);
78 llist_insert_tail (&list, &node3);
79 llist_insert_tail (&list, &node4);
80 llist_insert_head (&list, &node1);
82 printf (
"%d\n", llist_is_head (&list, &node1));
83 printf (
"%d\n", llist_is_tail (&list, &node4));
84 printf (
"%d\n", llist_is_head (&list, &node4));
85 printf (
"%d\n", llist_is_tail (&list, &node1));
86 printf (
"%d\n", llist_is_end (&list, &list));
87 printf (
"%d\n", llist_is_member (&list, &node3));
88 printf (
"%d\n", llist_is_member (&list, &nil));
90 printf (
"%d\n", llist_is_before_after (&list, &node1, &node3));
91 printf (
"%d\n", llist_is_before_after (&list, &node3, &node1));
92 printf (
"%d\n", llist_is_before_after (&list, &node1, &nil));
104 llist_insert_tail (&list, &node2);
105 llist_insert_tail (&list, &node3);
106 llist_insert_tail (&list, &node4);
107 llist_insert_head (&list, &node1);
111 if(itr == &node1) printf (
"node1 ");
112 else if(itr == &node2) printf (
"node2 ");
113 else if(itr == &node3) printf (
"node3 ");
114 else if(itr == &node4) printf (
"node4 ");
115 else printf (
"unknown ");
120 llist_unlink (&node2);
121 llist_unlink (&node3);
125 if(itr == &node1) printf (
"node1 ");
126 else if(itr == &node2) printf (
"node2 ");
127 else if(itr == &node3) printf (
"node3 ");
128 else if(itr == &node4) printf (
"node4 ");
129 else printf (
"unknown ");
132 printf (
"%d\n", llist_is_empty (&node2));
133 printf (
"%d\n", llist_is_empty (&node3));
134 printf (
"%d\n", llist_is_empty (&nil));
146 llist_insert_tail (&list, &node2);
147 llist_insert_tail (&list, &node3);
148 llist_insert_tail (&list, &node4);
149 llist_insert_head (&list, &node1);
153 if(itr == &node1) printf (
"node1 ");
154 else if(itr == &node2) printf (
"node2 ");
155 else if(itr == &node3) printf (
"node3 ");
156 else if(itr == &node4) printf (
"node4 ");
157 else printf (
"unknown ");
166 if(itr == &node1) printf (
"node1 ");
167 else if(itr == &node2) printf (
"node2 ");
168 else if(itr == &node3) printf (
"node3 ");
169 else if(itr == &node4) printf (
"node4 ");
170 else printf (
"unknown ");
174 llist_insert_tail (&list, &node2);
175 llist_insert_tail (&list, &node3);
176 llist_insert_tail (&list, &node4);
177 llist_insert_head (&list, &node1);
184 if(itr == &node1) printf (
"node1 ");
185 else if(itr == &node2) printf (
"node2 ");
186 else if(itr == &node3) printf (
"node3 ");
187 else if(itr == &node4) printf (
"node4 ");
188 else printf (
"unknown ");
197 llist_init (&source);
200 llist_init (&something);
202 llist_insert_head (&source, &something);
204 llist target = {NULL,NULL};
208 llist_relocate (&target);
209 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.