1 #define MAIN(x) slist##x
5 static a_size
a_slist_len(a_slist
const *ctx
)
8 a_slist_foreach(it
, ctx
) { ++count
; }
12 static void test(void)
19 a_slist
*list1
= a_new(a_slist
, A_NULL
, 1);
21 for (int i
= 0; i
!= 10; ++i
)
23 data
*node
= a_new(data
, A_NULL
, 1);
25 a_slist_add_tail(list1
, &node
->node
);
27 a_slist
*list2
= a_new(a_slist
, A_NULL
, 1);
29 for (int i
= 14; i
!= 9; --i
)
31 data
*node
= a_new(data
, A_NULL
, 1);
33 a_slist_add_head(list2
, &node
->node
);
35 a_slist
*list3
= a_new(a_slist
, A_NULL
, 1);
37 for (int i
= 15; i
!= 20; ++i
)
39 data
*node
= a_new(data
, A_NULL
, 1);
41 a_slist_add(list3
, list3
->tail
, &node
->node
);
44 a_slist_mov(list2
, list3
, &list3
->head
);
46 a_slist_mov(list3
, list1
, list1
->tail
);
48 a_slist_foreach(it
, list1
)
50 data
*node
= a_slist_entry(it
, data
, node
); // NOLINT(performance-no-int-to-ptr)
51 printf("%i ", node
->data
.i
);
53 printf("%" PRIz
"u", a_slist_len(list1
));
54 for (int i
= 0; i
!= 10; ++i
)
56 data
*node
= a_slist_entry_next(&list1
->head
, data
, node
); // NOLINT(performance-no-int-to-ptr)
57 a_slist_del_head(list1
);
60 a_slist_forsafe(it
, at
, list1
)
62 data
*node
= a_slist_entry(it
, data
, node
); // NOLINT(performance-no-int-to-ptr)
63 a_slist_del(list1
, at
);
67 if (list1
->head
.next
== &list1
->head
&&
68 list2
->head
.next
== &list2
->head
&&
69 list3
->head
.next
== &list3
->head
)
79 static void null(void)
81 static a_slist_node node1
= A_SLIST_NODE
;
82 static a_slist_node node2
= A_SLIST_NODE
;
83 static a_slist list1
= A_SLIST_INIT(list1
);
84 static a_slist list2
= A_SLIST_INIT(list2
);
88 a_slist_mov(&list2
, &list1
, &list1
.head
);
89 a_slist_mov(&list2
, &list1
, list1
.tail
);
90 a_slist_del(&list1
, &list1
.head
);
91 a_slist_del(&list1
, list1
.tail
);
92 a_slist_del_head(&list2
);
93 a_slist_del_head(&list2
);
97 a_slist_add(&list1
, &list1
.head
, &node1
);
98 a_slist_add(&list1
, &list1
.head
, &node1
);
99 a_slist_del(&list1
, &node1
);
100 a_slist_add(&list1
, list1
.tail
, &node1
);
101 a_slist_add(&list1
, &node1
, &node1
);
102 a_slist_add_head(&list1
, &node1
);
103 a_slist_add_tail(&list2
, &node2
);
104 a_slist_mov(&list2
, &list1
, &list1
.head
);
105 a_slist_mov(&list2
, &list1
, list1
.tail
);
108 int main(int argc
, char *argv
[]) // NOLINT(misc-definitions-in-headers)
112 printf("%s\n", A_FUNC
);