summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/new_vec.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/new_vec.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/new_vec.c')
-rw-r--r--misc/examples/new_vec.c43
1 files changed, 0 insertions, 43 deletions
diff --git a/misc/examples/new_vec.c b/misc/examples/new_vec.c
deleted file mode 100644
index 88efd55a..00000000
--- a/misc/examples/new_vec.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <stdio.h>
-#include <stc/forward.h>
-
-forward_cvec(cvec_i32, int);
-forward_cvec(cvec_pnt, struct Point);
-
-typedef struct MyStruct {
- cvec_i32 intvec;
- cvec_pnt pntvec;
-} MyStruct;
-
-#define i_key int
-#define i_tag i32
-#define i_is_forward
-#include <stc/cvec.h>
-
-typedef struct Point { int x, y; } Point;
-
-#define i_key Point
-#define i_tag pnt
-#define i_less(a, b) a->x < b->x || (a->x == b->x && a->y < b->y)
-#define i_eq(a, b) a->x == b->x && a->y == b->y
-#define i_is_forward
-#include <stc/cvec.h>
-
-int main(void)
-{
- MyStruct my = {0};
-
- cvec_pnt_push(&my.pntvec, c_LITERAL(Point){42, 14});
- cvec_pnt_push(&my.pntvec, c_LITERAL(Point){32, 94});
- cvec_pnt_push(&my.pntvec, c_LITERAL(Point){62, 81});
- cvec_pnt_push(&my.pntvec, c_LITERAL(Point){32, 91});
-
- cvec_pnt_sort(&my.pntvec);
-
- c_foreach (i, cvec_pnt, my.pntvec)
- printf(" (%d %d)", i.ref->x, i.ref->y);
- puts("");
-
- cvec_i32_drop(&my.intvec);
- cvec_pnt_drop(&my.pntvec);
-}