diff options
| author | Tyge Løvset <[email protected]> | 2023-01-19 19:27:07 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-01-19 19:27:07 +0100 |
| commit | 5aa48d538569463ffeda976d21f79edc5f276be4 (patch) | |
| tree | 6bbd87bc9e5041b2c3b69e14ec175536b8418630 /misc/examples | |
| parent | 0c4c4f8bba17562735b67b2923cd23c773aa53a7 (diff) | |
| download | STC-modified-5aa48d538569463ffeda976d21f79edc5f276be4.tar.gz STC-modified-5aa48d538569463ffeda976d21f79edc5f276be4.zip | |
Add a from_n() method to containers (and put_n() to maps), to support new initialization.
Diffstat (limited to 'misc/examples')
| -rw-r--r-- | misc/examples/printspan.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/misc/examples/printspan.c b/misc/examples/printspan.c index a897e669..6292cecf 100644 --- a/misc/examples/printspan.c +++ b/misc/examples/printspan.c @@ -1,12 +1,15 @@ // printspan.c #include <stdio.h> +#include <stc/cstr.h> #define i_val int #include <stc/cvec.h> #define i_val int #include <stc/cstack.h> #define i_val int #include <stc/cdeq.h> +#define i_val_str +#include <stc/cset.h> #include <stc/cspan.h> using_cspan(ispan, int, 1); @@ -21,22 +24,28 @@ int main() { c_AUTO (cvec_int, vec) c_AUTO (cstack_int, stk) c_AUTO (cdeq_int, deq) + c_AUTO (cset_str, set) { int arr[] = {1, 2, 3, 4, 5}; ispan sp = cspan_from_array(arr); printMe((ispan)cspan_subspan(&sp, 1, 3)); - printMe((ispan)cspan_from_list(int, {1, 2, 3, 4})); + printMe(c_initialize(ispan, {1, 2, 3, 4})); printMe((ispan)cspan_from_array(arr)); c_FORLIST (i, int, {1, 2, 3, 4, 5, 6}) cvec_int_push(&vec, *i.ref); printMe((ispan)cspan_from(&vec)); - c_FORLIST (i, int, {1, 2, 3, 4, 5, 6, 7}) cstack_int_push(&stk, *i.ref); + stk = c_initialize(cstack_int, {1, 2, 3, 4, 5, 6, 7}); printMe((ispan)cspan_from(&stk)); - c_FORLIST (i, int, {1, 2, 3, 4, 5, 6, 7, 8}) cdeq_int_push_front(&deq, *i.ref); + deq = c_initialize(cdeq_int, {1, 2, 3, 4, 5, 6, 7, 8}); printMe((ispan)cspan_from(&deq)); + + set = c_initialize(cset_str, {"1", "2", "3", "4", "5", "6", "7", "8", "9"}); + printf("%d\n", (int)cset_str_size(&set)); + c_FOREACH (e, cset_str, set) printf("%s ", cstr_str(e.ref)); + puts(""); } } |
