summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/list_splice.c
diff options
context:
space:
mode:
authortylov <[email protected]>2023-07-20 15:09:10 +0200
committertylov <[email protected]>2023-07-20 15:12:29 +0200
commit900295256d825fc323149cd223c49787f32a3696 (patch)
tree6c79cf4209e3975bb6865e2940b9cb56ea469c73 /misc/examples/list_splice.c
parent224a04f7fa7549ed94d2a1415eb25829e39a7cca (diff)
downloadSTC-modified-900295256d825fc323149cd223c49787f32a3696.tar.gz
STC-modified-900295256d825fc323149cd223c49787f32a3696.zip
Moved examples to sub-directories. Added cotask1.c cotask2.c examples.
Diffstat (limited to 'misc/examples/list_splice.c')
-rw-r--r--misc/examples/list_splice.c38
1 files changed, 0 insertions, 38 deletions
diff --git a/misc/examples/list_splice.c b/misc/examples/list_splice.c
deleted file mode 100644
index f1fd6e1f..00000000
--- a/misc/examples/list_splice.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <stdio.h>
-
-#define i_key int
-#define i_tag i
-#include <stc/clist.h>
-
-void print_ilist(const char* s, clist_i list)
-{
- printf("%s", s);
- c_foreach (i, clist_i, list) {
- printf(" %d", *i.ref);
- }
- puts("");
-}
-
-int main(void)
-{
- clist_i list1 = c_init(clist_i, {1, 2, 3, 4, 5});
- clist_i list2 = c_init(clist_i, {10, 20, 30, 40, 50});
-
- print_ilist("list1:", list1);
- print_ilist("list2:", list2);
-
- clist_i_iter it = clist_i_advance(clist_i_begin(&list1), 2);
- it = clist_i_splice(&list1, it, &list2);
-
- puts("After splice");
- print_ilist("list1:", list1);
- print_ilist("list2:", list2);
-
- clist_i_splice_range(&list2, clist_i_begin(&list2), &list1, it, clist_i_end(&list1));
-
- puts("After splice_range");
- print_ilist("list1:", list1);
- print_ilist("list2:", list2);
-
- c_drop(clist_i, &list1, &list2);
-}