diff options
| author | Tyge Løvset <[email protected]> | 2021-05-15 15:47:58 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-05-15 15:47:58 +0200 |
| commit | 915ccf1d811ae9a0469cddd8f2dc6370e835e24b (patch) | |
| tree | 81d82a35dacde0767a46317224343a82daef0fa7 /docs | |
| parent | ac20f731153747ec5cbfc5566cc149485e20002a (diff) | |
| download | STC-modified-915ccf1d811ae9a0469cddd8f2dc6370e835e24b.tar.gz STC-modified-915ccf1d811ae9a0469cddd8f2dc6370e835e24b.zip | |
API change: Renamed c_init() to c_var() to better describe it declares and initializes a container variable. Will create a version 2.0 RC release soon.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ccommon_api.md | 8 | ||||
| -rw-r--r-- | docs/clist_api.md | 8 | ||||
| -rw-r--r-- | docs/cmap_api.md | 2 | ||||
| -rw-r--r-- | docs/cset_api.md | 4 | ||||
| -rw-r--r-- | docs/csmap_api.md | 23 | ||||
| -rw-r--r-- | docs/csset_api.md | 4 |
6 files changed, 24 insertions, 25 deletions
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md index ec546dd6..afbcb8a7 100644 --- a/docs/ccommon_api.md +++ b/docs/ccommon_api.md @@ -2,10 +2,10 @@ The following handy macros are safe to use, i.e. have no side-effects. -### c_init, c_emplace -**c_init** declares and initializes any container with an array of elements. **c_emplace** adds elements to any existing container: +### c_var, c_emplace +**c_var** declares and initializes any container with an array of elements. **c_emplace** adds elements to any existing container: ```c -c_init(cvec_i, vec, {1, 2, 3}); // declare and emplace +c_var(cvec_i, vec, {1, 2, 3}); // declare and emplace c_emplace(cvec_i, vec, {4, 5, 6}); // adds to existing vec ``` @@ -41,7 +41,7 @@ c_forrange (i, int, 30, 0, -5) printf(" %d", i); ```c using_csset(x, int); ... -c_init (csset_x, set, {23, 3, 7, 5, 12}); +c_var (csset_x, set, {23, 3, 7, 5, 12}); c_foreach (i, csset_x, set) printf(" %d", *i.ref); // 3 5 7 12 23 csset_x_iter_t it = csset_x_find(&set, 7); diff --git a/docs/clist_api.md b/docs/clist_api.md index 9f7acb37..86063dbf 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -109,7 +109,7 @@ Interleave *push_front()* / *push_back()* then *sort()*: using_clist(d, double); int main() { - c_init (clist_d, list, { + c_var (clist_d, list, { 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0 }); @@ -148,7 +148,7 @@ using_clist(i, int); int main () { - c_init (clist_i, L, {10, 20, 30, 40, 50}); + c_var (clist_i, L, {10, 20, 30, 40, 50}); // 10 20 30 40 50 clist_i_iter_t it = clist_i_begin(&L); // ^ clist_i_next(&it); @@ -180,8 +180,8 @@ Splice `[30, 40]` from *L2* into *L1* before `3`: using_clist(i, int); int main() { - c_init (clist_i, L1, {1, 2, 3, 4, 5}); - c_init (clist_i, L2, {10, 20, 30, 40, 50}); + c_var (clist_i, L1, {1, 2, 3, 4, 5}); + c_var (clist_i, L2, {10, 20, 30, 40, 50}); clist_i_iter_t i = clist_i_fwd(clist_i_begin(&L1), 2); clist_i_iter_t j1 = clist_i_fwd(clist_i_begin(&L2), 2), j2 = clist_i_fwd(j1, 2); diff --git a/docs/cmap_api.md b/docs/cmap_api.md index 37bfe110..9fd96e5c 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -123,7 +123,7 @@ using_cmap_str(); int main() { // Create an unordered_map of three strings (that map to strings) - c_init (cmap_str, u, { + c_var (cmap_str, u, { {"RED", "#FF0000"}, {"GREEN", "#00FF00"}, {"BLUE", "#0000FF"} diff --git a/docs/cset_api.md b/docs/cset_api.md index 5a871dd5..6c6e9951 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -80,8 +80,8 @@ using_cset_str(); int main ()
{
cset_str first = cset_str_init(); // empty
- c_init (cset_str, second, {"red", "green", "blue"});
- c_init (cset_str, third, {"orange", "pink", "yellow"});
+ c_var (cset_str, second, {"red", "green", "blue"});
+ c_var (cset_str, third, {"orange", "pink", "yellow"});
cset_str fourth = cset_str_init();
cset_str_emplace(&fourth, "potatoes");
diff --git a/docs/csmap_api.md b/docs/csmap_api.md index 5b81f2e6..5b76f7bb 100644 --- a/docs/csmap_api.md +++ b/docs/csmap_api.md @@ -102,28 +102,27 @@ using_csmap_str(); int main() { - // Create an unordered_map of three strings (that map to strings) - c_init (csmap_str, u, { + // Create an unordered_map of three strings (maps to string) + c_var (csmap_str, colors, { {"RED", "#FF0000"}, {"GREEN", "#00FF00"}, {"BLUE", "#0000FF"} }); // Iterate and print keys and values of unordered map - c_foreach (n, csmap_str, u) { - printf("Key:[%s] Value:[%s]\n", n.ref->first.str, n.ref->second.str); + c_foreach (i, csmap_str, colors) { + printf("Key:[%s] Value:[%s]\n", i.ref->first.str, i.ref->second.str); } // Add two new entries to the unordered map - csmap_str_emplace(&u, "BLACK", "#000000"); - csmap_str_emplace(&u, "WHITE", "#FFFFFF"); + csmap_str_emplace(&colors, "BLACK", "#000000"); + csmap_str_emplace(&colors, "WHITE", "#FFFFFF"); // Output values by key - printf("The HEX of color RED is:[%s]\n", csmap_str_at(&u, "RED")->str); - printf("The HEX of color BLACK is:[%s]\n", csmap_str_at(&u, "BLACK")->str); + printf("The HEX of color RED is:[%s]\n", csmap_str_at(&colors, "RED")->str); + printf("The HEX of color BLACK is:[%s]\n", csmap_str_at(&colors, "BLACK")->str); - csmap_str_del(&u); - return 0; + csmap_str_del(&colors); } ``` Output: @@ -147,7 +146,7 @@ using_csmap_strval(id, int); int main() { uint32_t col = 0xcc7744ff; - c_init (csmap_id, idnames, { + c_var (csmap_id, idnames, { {100, "Red"}, {110, "Blue"}, }); @@ -155,7 +154,7 @@ int main() csmap_id_emplace_or_assign(&idnames, 110, "White"); /* put a constructed mapped value into map: */ csmap_id_insert_or_assign(&idnames, 120, cstr_from_fmt("#%08x", col)); - /* emplace inserts only when key does not exist: */ + /* emplace adds only when key does not exist: */ csmap_id_emplace(&idnames, 100, "Green"); c_foreach (i, csmap_id, idnames) diff --git a/docs/csset_api.md b/docs/csset_api.md index e4424837..9dd241f4 100644 --- a/docs/csset_api.md +++ b/docs/csset_api.md @@ -77,8 +77,8 @@ using_csset_str(); int main ()
{
csset_str first = csset_str_init(); // empty
- c_init (csset_str, second, {"red", "green", "blue"});
- c_init (csset_str, third, {"orange", "pink", "yellow"});
+ c_var (csset_str, second, {"red", "green", "blue"});
+ c_var (csset_str, third, {"orange", "pink", "yellow"});
csset_str fourth = csset_str_init();
csset_str_emplace(&fourth, "potatoes");
|
