diff options
| author | Tyge Løvset <[email protected]> | 2023-04-08 22:37:06 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-08 22:37:06 +0200 |
| commit | 43120f2863a67db416ec3b379eb820e2704cafb7 (patch) | |
| tree | f3b9917940f94c1582bc39ea6f56b735295ec861 /docs/csset_api.md | |
| parent | e8be14dfc894eeac859f0287d4d5b4f4745c0585 (diff) | |
| parent | 6426ac05eb8c4dc1ab22aae2eb4139f9671981b7 (diff) | |
| download | STC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.tar.gz STC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.zip | |
Merge pull request #53 from tylov/dev42
Version 4.2 RC
Diffstat (limited to 'docs/csset_api.md')
| -rw-r--r-- | docs/csset_api.md | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/docs/csset_api.md b/docs/csset_api.md index 80ee1844..1869327c 100644 --- a/docs/csset_api.md +++ b/docs/csset_api.md @@ -18,7 +18,6 @@ See the c++ class [std::set](https://en.cppreference.com/w/cpp/container/set) fo #define i_keyfrom // convertion func i_keyraw => i_key - defaults to plain copy #define i_keyto // convertion func i_key* => i_keyraw - defaults to plain copy -#define i_cmp_functor // advanced, see examples/functor.c for similar usage. #define i_tag // alternative typename: csset_{i_tag}. i_tag defaults to i_val #define i_ssize // defaults to int32_t #include <stc/csset.h> @@ -80,33 +79,38 @@ csset_X_value csset_X_value_clone(csset_X_value val); ```c #include <stc/cstr.h> +#define i_type SSet #define i_key_str #include <stc/csset.h> int main () { - c_auto (csset_str, first, second, third) - c_auto (csset_str, fourth, fifth) - { - second = c_make(csset_str, {"red", "green", "blue"}); - - c_forlist (i, const char*, {"orange", "pink", "yellow"}) - csset_str_emplace(&third, *i.ref); - - csset_str_emplace(&fourth, "potatoes"); - csset_str_emplace(&fourth, "milk"); - csset_str_emplace(&fourth, "flour"); - - fifth = csset_str_clone(second); - c_foreach (i, csset_str, third) - csset_str_emplace(&fifth, cstr_str(i.ref)); - c_foreach (i, csset_str, fourth) - csset_str_emplace(&fifth, cstr_str(i.ref)); - - printf("fifth contains:\n\n"); - c_foreach (i, csset_str, fifth) - printf("%s\n", cstr_str(i.ref)); - } + SSet second={0}, third={0}, fourth={0}, fifth={0}; + + second = c_make(SSet, {"red", "green", "blue"}); + + c_forlist (i, const char*, {"orange", "pink", "yellow"}) + SSet_emplace(&third, *i.ref); + + SSet_emplace(&fourth, "potatoes"); + SSet_emplace(&fourth, "milk"); + SSet_emplace(&fourth, "flour"); + + // Copy all to fifth: + + fifth = SSet_clone(second); + + c_foreach (i, SSet, third) + SSet_emplace(&fifth, cstr_str(i.ref)); + + c_foreach (i, SSet, fourth) + SSet_emplace(&fifth, cstr_str(i.ref)); + + printf("fifth contains:\n\n"); + c_foreach (i, SSet, fifth) + printf("%s\n", cstr_str(i.ref)); + + c_drop(SSet, &second, &third, &fourth, &fifth); } ``` Output: |
