diff options
| author | tylov <[email protected]> | 2023-07-20 15:09:10 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-07-20 15:12:29 +0200 |
| commit | 900295256d825fc323149cd223c49787f32a3696 (patch) | |
| tree | 6c79cf4209e3975bb6865e2940b9cb56ea469c73 /misc/examples/printspan.c | |
| parent | 224a04f7fa7549ed94d2a1415eb25829e39a7cca (diff) | |
| download | STC-modified-900295256d825fc323149cd223c49787f32a3696.tar.gz STC-modified-900295256d825fc323149cd223c49787f32a3696.zip | |
Moved examples to sub-directories. Added cotask1.c cotask2.c examples.
Diffstat (limited to 'misc/examples/printspan.c')
| -rw-r--r-- | misc/examples/printspan.c | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/misc/examples/printspan.c b/misc/examples/printspan.c deleted file mode 100644 index cd3c5f4f..00000000 --- a/misc/examples/printspan.c +++ /dev/null @@ -1,52 +0,0 @@ -// printspan.c - -#include <stdio.h> -#define i_implement -#include <stc/cstr.h> -#define i_key int -#include <stc/cvec.h> -#define i_key int -#include <stc/cstack.h> -#define i_key_str -#include <stc/csset.h> - -#include <stc/cspan.h> -using_cspan(intspan, int, 1); - -void printMe(intspan container) { - printf("%d:", (int)cspan_size(&container)); - c_foreach (e, intspan, container) - printf(" %d", *e.ref); - puts(""); -} - -int main(void) -{ - intspan sp1 = cspan_init(intspan, {1, 2}); - printMe( sp1 ); - - printMe( c_init(intspan, {1, 2, 3}) ); - - int arr[] = {1, 2, 3, 4, 5, 6}; - intspan sp2 = cspan_from_array(arr); - printMe( c_LITERAL(intspan)cspan_subspan(&sp2, 1, 4) ); - - cvec_int vec = c_init(cvec_int, {1, 2, 3, 4, 5}); - printMe( c_LITERAL(intspan)cspan_from(&vec) ); - - printMe( sp2 ); - - cstack_int stk = c_init(cstack_int, {1, 2, 3, 4, 5, 6, 7}); - printMe( c_LITERAL(intspan)cspan_from(&stk) ); - - csset_str set = c_init(csset_str, {"5", "7", "4", "3", "8", "2", "1", "9", "6"}); - printf("%d:", (int)csset_str_size(&set)); - c_foreach (e, csset_str, set) - printf(" %s", cstr_str(e.ref)); - puts(""); - - // cleanup - cvec_int_drop(&vec); - cstack_int_drop(&stk); - csset_str_drop(&set); -} |
