diff options
| author | Tyge Løvset <[email protected]> | 2022-09-23 07:15:41 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-09-23 07:15:41 +0200 |
| commit | 34bec4fdf406caff8492d53f0afc80df5d75bba4 (patch) | |
| tree | 94252139eb34cb37f561ec5a6b9513629b2a81a5 /examples | |
| parent | d70bcf4d875c14da30a39acfc37d00391cc1e7a9 (diff) | |
| download | STC-modified-34bec4fdf406caff8492d53f0afc80df5d75bba4.tar.gz STC-modified-34bec4fdf406caff8492d53f0afc80df5d75bba4.zip | |
Deprecated c_forarray, c_forarray_p macros - both replaced by c_forlist, and is consistent with other c_for* macros.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/arcvec_erase.c | 4 | ||||
| -rw-r--r-- | examples/city.c | 6 | ||||
| -rw-r--r-- | examples/convert.c | 4 | ||||
| -rw-r--r-- | examples/csmap_erase.c | 4 | ||||
| -rw-r--r-- | examples/csmap_find.c | 4 | ||||
| -rw-r--r-- | examples/csmap_insert.c | 6 | ||||
| -rw-r--r-- | examples/csset_erase.c | 4 | ||||
| -rw-r--r-- | examples/forfilter.c | 34 | ||||
| -rw-r--r-- | examples/inits.c | 12 | ||||
| -rw-r--r-- | examples/list.c | 4 | ||||
| -rw-r--r-- | examples/list_erase.c | 4 | ||||
| -rw-r--r-- | examples/list_splice.c | 8 | ||||
| -rw-r--r-- | examples/lower_bound.c | 8 | ||||
| -rwxr-xr-x | examples/make.sh | 4 | ||||
| -rw-r--r-- | examples/mmap.c | 12 | ||||
| -rw-r--r-- | examples/music_arc.c | 8 | ||||
| -rw-r--r-- | examples/new_list.c | 8 | ||||
| -rw-r--r-- | examples/new_map.c | 12 | ||||
| -rw-r--r-- | examples/new_smap.c | 8 | ||||
| -rw-r--r-- | examples/person_arc.c | 4 | ||||
| -rw-r--r-- | examples/phonebook.c | 8 | ||||
| -rw-r--r-- | examples/priority.c | 4 | ||||
| -rw-r--r-- | examples/shape.c | 8 | ||||
| -rw-r--r-- | examples/sidebyside.cpp | 4 | ||||
| -rw-r--r-- | examples/words.c | 4 |
25 files changed, 96 insertions, 90 deletions
diff --git a/examples/arcvec_erase.c b/examples/arcvec_erase.c index 2c9a3daa..63b646a3 100644 --- a/examples/arcvec_erase.c +++ b/examples/arcvec_erase.c @@ -19,8 +19,8 @@ int main() { c_auto (Vec, vec) { - c_forarray (int, v, {2012, 1990, 2012, 2019, 2015}) - Vec_emplace(&vec, *v); + c_forlist (i, int, {2012, 1990, 2012, 2019, 2015}) + Vec_emplace(&vec, *i.ref); // clone the second 2012 and push it back. // note: cloning make sure that vec.data[2] has ref count 2. diff --git a/examples/city.c b/examples/city.c index c6a9417f..c98d3098 100644 --- a/examples/city.c +++ b/examples/city.c @@ -51,14 +51,12 @@ int main(void) c_auto (Cities, cities, copy) c_auto (CityMap, map) { - c_forarray (City, c, { + c_forlist (i, City, { {cstr_new("New York"), cstr_new("US"), 4.3, 23.2, 9000000}, {cstr_new("Paris"), cstr_new("France"), 4.3, 23.2, 9000000}, {cstr_new("Berlin"), cstr_new("Germany"), 4.3, 23.2, 9000000}, {cstr_new("London"), cstr_new("UK"), 4.3, 23.2, 9000000}, - }) { - Cities_emplace(&cities, *c); - } + }) Cities_emplace(&cities, *i.ref); copy = Cities_clone(cities); // share each element! diff --git a/examples/convert.c b/examples/convert.c index 5d58574d..74f4f865 100644 --- a/examples/convert.c +++ b/examples/convert.c @@ -17,11 +17,11 @@ int main() c_auto (cvec_str, keys, values) c_auto (clist_str, list) { - c_forarray (cmap_str_raw, v, { + c_forlist (i, cmap_str_raw, { {"green", "#00ff00"}, {"blue", "#0000ff"}, {"yellow", "#ffff00"}, - }) cmap_str_emplace(&map, c_pair(v)); + }) cmap_str_emplace(&map, c_pair(i.ref)); puts("MAP:"); c_foreach (i, cmap_str, map) diff --git a/examples/csmap_erase.c b/examples/csmap_erase.c index cbcc2607..e99a4d7a 100644 --- a/examples/csmap_erase.c +++ b/examples/csmap_erase.c @@ -37,13 +37,13 @@ int main() c_auto (mymap, m2) { // Fill in some data to test with, one at a time - c_forarray (mymap_raw, v, { + c_forlist (i, mymap_raw, { {10, "Bob"}, {11, "Rob"}, {12, "Robert"}, {13, "Bert"}, {14, "Bobby"}, - }) mymap_emplace(&m2, v->first, v->second); + }) mymap_emplace(&m2, c_pair(i.ref)); puts("Starting data of map m2 is:"); printmap(m2); diff --git a/examples/csmap_find.c b/examples/csmap_find.c index ae8aeb85..e7a7112c 100644 --- a/examples/csmap_find.c +++ b/examples/csmap_find.c @@ -45,8 +45,8 @@ int main() c_auto (csmap_istr, m1) c_auto (cvec_istr, v) { - c_forarray (csmap_istr_raw, v, {{40, "Zr"}, {45, "Rh"}}) - csmap_istr_emplace(&m1, c_pair(v)); + c_forlist (i, csmap_istr_raw, {{40, "Zr"}, {45, "Rh"}}) + csmap_istr_emplace(&m1, c_pair(i.ref)); puts("The starting map m1 is (key, value):"); print_collection_csmap_istr(&m1); diff --git a/examples/csmap_insert.c b/examples/csmap_insert.c index 7652fd59..71c8cfe9 100644 --- a/examples/csmap_insert.c +++ b/examples/csmap_insert.c @@ -101,9 +101,9 @@ int main() c_auto (csmap_ii, m4) { // Insert the elements from an initializer_list - c_forarray (csmap_ii_raw, v, {{ 4, 44 }, { 2, 22 }, { 3, 33 }, - { 1, 11 }, { 5, 55 }}) - csmap_ii_insert(&m4, v->first, v->second); + c_forlist (i, csmap_ii_raw, {{ 4, 44 }, { 2, 22 }, { 3, 33 }, + { 1, 11 }, { 5, 55 }}) + csmap_ii_insert(&m4, c_pair(i.ref)); puts("After initializer_list insertion, m4 contains:"); print_ii(m4); diff --git a/examples/csset_erase.c b/examples/csset_erase.c index 9ca23aab..33eb2163 100644 --- a/examples/csset_erase.c +++ b/examples/csset_erase.c @@ -7,8 +7,8 @@ int main() { c_auto (csset_int, set) { - c_forarray (int, v, {30, 20, 80, 40, 60, 90, 10, 70, 50}) - csset_int_insert(&set, *v); + c_forlist (i, int, {30, 20, 80, 40, 60, 90, 10, 70, 50}) + csset_int_insert(&set, *i.ref); c_foreach (k, csset_int, set) printf(" %d", *k.ref); diff --git a/examples/forfilter.c b/examples/forfilter.c index c7d3fae0..409d83e3 100644 --- a/examples/forfilter.c +++ b/examples/forfilter.c @@ -11,27 +11,32 @@ #define i_val_bind csview #include <stc/cstack.h> +// filters and transforms: +#define flt_drop(i, n) (i.index >= (n)) +#define flt_remove(i, x) (*i.ref != (x)) +#define flt_take(i, n) (i.count < (n)) +#define flt_even(i) ((*i.ref & 1) == 0) +#define trf_square(i) (*i.ref * *i.ref) + void demo1(void) { c_auto (IVec, vec) { - c_forarray (int, v, {0, 1, 2, 3, 4, 5, 80, 6, 7, 80, 8, 9, 80, 10, 11, 12, 13}) - IVec_push(&vec, *v); + c_forlist (i, int, {0, 1, 2, 3, 4, 5, 80, 6, 7, 80, 8, 9, 80, 10, 11, 12, 13, 14, 15, 80, 16, 17}) + IVec_push(&vec, *i.ref); c_forfilter (i, IVec, vec, *i.ref != 80) printf(" %d", *i.ref); puts(""); - #define flt_drop(i, n) (i.index >= (n)) - #define flt_remove(i, x) (*i.ref != (x)) - #define flt_take(i, n) (i.taken < (n)) - #define flt_even(i) ((*i.ref & 1) == 0) - + int res, sum = 0; c_forfilter (i, IVec, vec, flt_drop(i, 3) && flt_even(i) && flt_remove(i, 80) - , flt_take(i, 5)) - printf(" %d", *i.ref); - puts(""); + , flt_take(i, 5)) { + sum += res = trf_square(i); + printf(" %d", res); + } + printf("\nsum: %d\n", sum); } } @@ -94,9 +99,12 @@ void demo4(void) { csview s = c_sv("ab123cReAghNGnΩoEp"); cstr out = cstr_null; - c_forfilter (i, csview, s, utf8_isupper(utf8_peek(i.ref))) - cstr_push(&out, i.ref); - //cstr_append_sv(&out, i.it.u8.chr); + + c_forfilter (i, csview, s, utf8_isupper(utf8_peek(i.ref))) { + char buf[4]; + utf8_encode(buf, utf8_tolower(utf8_peek(i.ref))); + cstr_push(&out, buf); + } printf("%s\n", cstr_str(&out)); } diff --git a/examples/inits.c b/examples/inits.c index 9ce96dc9..ab6cdce9 100644 --- a/examples/inits.c +++ b/examples/inits.c @@ -67,7 +67,7 @@ int main(void) // CMAP CNT c_auto (cmap_cnt, countries) { - c_forarray (cmap_cnt_raw, v, { + c_forlist (i, cmap_cnt_raw, { {"Norway", 100}, {"Denmark", 50}, {"Iceland", 10}, @@ -76,7 +76,7 @@ int main(void) {"Germany", 10}, {"Spain", 10}, {"France", 10}, - }) cmap_cnt_emplace(&countries, v->first, v->second); + }) cmap_cnt_emplace(&countries, c_pair(i.ref)); cmap_cnt_emplace(&countries, "Greenland", 0).ref->second += 20; cmap_cnt_emplace(&countries, "Sweden", 0).ref->second += 20; @@ -91,8 +91,8 @@ int main(void) // CVEC PAIR c_auto (cvec_ip, pairs1) { - c_forarray (ipair_t, p, {{5, 6}, {3, 4}, {1, 2}, {7, 8}}) - cvec_ip_push_back(&pairs1, *p); + c_forlist (i, ipair_t, {{5, 6}, {3, 4}, {1, 2}, {7, 8}}) + cvec_ip_push_back(&pairs1, *i.ref); cvec_ip_sort(&pairs1); @@ -104,8 +104,8 @@ int main(void) // CLIST PAIR c_auto (clist_ip, pairs2) { - c_forarray (ipair_t, p, {{5, 6}, {3, 4}, {1, 2}, {7, 8}}) - clist_ip_push_back(&pairs2, *p); + c_forlist (i, ipair_t, {{5, 6}, {3, 4}, {1, 2}, {7, 8}}) + clist_ip_push_back(&pairs2, *i.ref); clist_ip_sort(&pairs2); diff --git a/examples/list.c b/examples/list.c index d5f3996c..2f5fa964 100644 --- a/examples/list.c +++ b/examples/list.c @@ -37,8 +37,8 @@ int main() { puts(""); clist_fx_clear(&list); - c_forarray (int, v, {10, 20, 30, 40, 30, 50}) - clist_fx_push_back(&list, *v); + c_forlist (i, int, {10, 20, 30, 40, 30, 50}) + clist_fx_push_back(&list, *i.ref); const double* v = clist_fx_get(&list, 30); printf("found: %f\n", *v); diff --git a/examples/list_erase.c b/examples/list_erase.c index 71d1f55f..c1a2aa97 100644 --- a/examples/list_erase.c +++ b/examples/list_erase.c @@ -9,8 +9,8 @@ int main () { c_with (IList L = IList_init(), IList_drop(&L)) { - c_forarray (int, i, {10, 20, 30, 40, 50}) - IList_push(&L, *i); + c_forlist (i, int, {10, 20, 30, 40, 50}) + IList_push(&L, *i.ref); c_foreach (x, IList, L) printf("%d ", *x.ref); diff --git a/examples/list_splice.c b/examples/list_splice.c index 8ba022f8..f7bac0d6 100644 --- a/examples/list_splice.c +++ b/examples/list_splice.c @@ -18,11 +18,11 @@ int main () { c_auto (clist_i, list1, list2) { - c_forarray (int, v, {1, 2, 3, 4, 5}) - clist_i_push_back(&list1, *v); + c_forlist (i, int, {1, 2, 3, 4, 5}) + clist_i_push_back(&list1, *i.ref); - c_forarray (int, v, {10, 20, 30, 40, 50}) - clist_i_push_back(&list2, *v); + c_forlist (i, int, {10, 20, 30, 40, 50}) + clist_i_push_back(&list2, *i.ref); print_ilist("list1:", list1); print_ilist("list2:", list2); diff --git a/examples/lower_bound.c b/examples/lower_bound.c index c8beed6f..2477bc14 100644 --- a/examples/lower_bound.c +++ b/examples/lower_bound.c @@ -13,8 +13,8 @@ int main() { int key, *res; - c_forarray (int, t, {40, 600, 1, 7000, 2, 500, 30}) - cvec_int_push(&vec, *t); + c_forlist (i, int, {40, 600, 1, 7000, 2, 500, 30}) + cvec_int_push(&vec, *i.ref); cvec_int_sort(&vec); @@ -40,8 +40,8 @@ int main() { int key, *res; - c_forarray (int, t, {40, 600, 1, 7000, 2, 500, 30}) - csset_int_push(&set, *t); + c_forlist (i, int, {40, 600, 1, 7000, 2, 500, 30}) + csset_int_push(&set, *i.ref); key = 500; res = csset_int_lower_bound(&set, key).ref; diff --git a/examples/make.sh b/examples/make.sh index e5efde07..ff452ce8 100755 --- a/examples/make.sh +++ b/examples/make.sh @@ -1,8 +1,8 @@ #!/bin/bash cc='gcc -s -O2 -Wall -std=c99 -pedantic -Wfatal-errors' #cc='tcc -s -O2 -Wall -std=c99 -pedantic -Wfatal-errors' -#cc='clang -s -O2 -Wall -std=c99 -pedantic' -#cc='clang -s -O2 -Wall -std=c99 -pedantic -DSTC_CSTR_V1 -DSTC_CSMAP_V1' +#cc='clang -s -O2 -Wall -std=c99 -pedantic -Wfatal-errors' +#cc='clang -s -O2 -Wall -std=c99 -pedantic -Wfatal-errors -DSTC_CSTR_V1 -DSTC_CSMAP_V1' #cc='gcc -x c++ -s -O2 -Wall -std=c++20' #cc='g++ -x c++ -s -O2 -Wall' #cc='clang' diff --git a/examples/mmap.c b/examples/mmap.c index ed78d2af..b7fff59a 100644 --- a/examples/mmap.c +++ b/examples/mmap.c @@ -38,8 +38,8 @@ int main() typedef struct {int a; const char* b;} pair; // list-initialize - c_forarray (pair, v, {{2, "foo"}, {2, "bar"}, {3, "baz"}, {1, "abc"}, {5, "def"}}) - insert(&mmap, v->a, v->b); + c_forlist (i, pair, {{2, "foo"}, {2, "bar"}, {3, "baz"}, {1, "abc"}, {5, "def"}}) + insert(&mmap, i.ref->a, i.ref->b); print("#1", mmap); // insert using value_type @@ -54,8 +54,8 @@ int main() print("#4", mmap); // insert using initialization_list - c_forarray (pair, v, {{5, "one"}, {5, "two"}}) - insert(&mmap, v->a, v->b); + c_forlist (i, pair, {{5, "one"}, {5, "two"}}) + insert(&mmap, i.ref->a, i.ref->b); print("#5", mmap); // FOLLOWING NOT IN ORIGINAL EXAMPLE: @@ -65,8 +65,8 @@ int main() Multimap_clear(&mmap); - c_forarray (pair, v, {{1, "ä"}, {2, "ё"}, {2, "ö"}, {3, "ü"}}) - insert(&mmap, v->a, v->b); + c_forlist (i, pair, {{1, "ä"}, {2, "ё"}, {2, "ö"}, {3, "ü"}}) + insert(&mmap, i.ref->a, i.ref->b); print("#6", mmap); } } diff --git a/examples/music_arc.c b/examples/music_arc.c index a6b5d90f..616114fc 100644 --- a/examples/music_arc.c +++ b/examples/music_arc.c @@ -35,11 +35,11 @@ void example3() { c_auto (SongVec, vec1, vec2) { - c_forarray (Song, v, { + c_forlist (i, Song, { Song_from("Bob Dylan", "The Times They Are A Changing"), Song_from("Aretha Franklin", "Bridge Over Troubled Water"), Song_from("Thalia", "Entre El Mar y Una Estrella") - }) SongVec_emplace(&vec1, *v); + }) SongVec_emplace(&vec1, *i.ref); // Share all entries in vec with vec2, except Bob Dylan. c_foreach (s, SongVec, vec1) @@ -53,9 +53,9 @@ void example3() // SongVec_push(&vec2, SongArc_from(Song_from("Rihanna", "Stay"))); // We now have two vectors with some shared, some unique entries. - c_forarray (SongVec, v, {vec1, vec2}) { + c_forlist (i, SongVec, {vec1, vec2}) { puts("VEC:"); - c_foreach (s, SongVec, *v) + c_foreach (s, SongVec, *i.ref) printf(" %s - %s, REFS: %ld\n", cstr_str(&s.ref->get->artist), cstr_str(&s.ref->get->title), *s.ref->use_count); diff --git a/examples/new_list.c b/examples/new_list.c index e760a093..87260931 100644 --- a/examples/new_list.c +++ b/examples/new_list.c @@ -39,8 +39,8 @@ int main() clist_i32_push_back(&lst, 123); c_auto (clist_pnt, plst) { - c_forarray (Point, v, {{42, 14}, {32, 94}, {62, 81}}) - clist_pnt_push_back(&plst, *v); + c_forlist (i, Point, {{42, 14}, {32, 94}, {62, 81}}) + clist_pnt_push_back(&plst, *i.ref); clist_pnt_sort(&plst); @@ -50,8 +50,8 @@ int main() } c_auto (clist_float, flst) { - c_forarray (float, v, {123.3f, 321.2f, -32.2f, 78.2f}) - clist_float_push_back(&flst, *v); + c_forlist (i, float, {123.3f, 321.2f, -32.2f, 78.2f}) + clist_float_push_back(&flst, *i.ref); c_foreach (i, clist_float, flst) printf(" %g", *i.ref); } diff --git a/examples/new_map.c b/examples/new_map.c index c94c2b44..7f12c43c 100644 --- a/examples/new_map.c +++ b/examples/new_map.c @@ -49,23 +49,23 @@ int main() { cmap_int_insert(&map, 123, 321); - c_forarray (cmap_pnt_raw, v, {{{42, 14}, 1}, {{32, 94}, 2}, {{62, 81}, 3}}) - cmap_pnt_insert(&pmap, v->first, v->second); + c_forlist (i, cmap_pnt_raw, {{{42, 14}, 1}, {{32, 94}, 2}, {{62, 81}, 3}}) + cmap_pnt_insert(&pmap, c_pair(i.ref)); c_foreach (i, cmap_pnt, pmap) printf(" (%d, %d: %d)", i.ref->first.x, i.ref->first.y, i.ref->second); puts(""); - c_forarray (cmap_str_raw, v, { + c_forlist (i, cmap_str_raw, { {"Hello, friend", "long time no see"}, {"So long, friend", "see you around"}, - }) cmap_str_emplace(&smap, v->first, v->second); + }) cmap_str_emplace(&smap, c_pair(i.ref)); - c_forarray_p (const char*, v, { + c_forlist (i, const char*, { "Hello, friend", "Nice to see you again", "So long, friend", - }) cset_str_emplace(&sset, *v); + }) cset_str_emplace(&sset, *i.ref); c_foreach (i, cset_str, sset) printf(" %s\n", cstr_str(i.ref)); diff --git a/examples/new_smap.c b/examples/new_smap.c index 7c2ddb35..154b04a3 100644 --- a/examples/new_smap.c +++ b/examples/new_smap.c @@ -47,11 +47,11 @@ int main() } c_auto (PMap, pmap) { - c_forarray (PMap_value, v, { + c_forlist (i, PMap_value, { {{42, 14}, 1}, {{32, 94}, 2}, {{62, 81}, 3}, - }) PMap_insert(&pmap, c_pair(v)); + }) PMap_insert(&pmap, c_pair(i.ref)); c_forpair (p, i, PMap, pmap) printf(" (%d,%d: %d)", _.p->x, _.p->y, *_.i); @@ -59,11 +59,11 @@ int main() } c_auto (SMap, smap) { - c_forarray (SMap_raw, v, { + c_forlist (i, SMap_raw, { {"Hello, friend", "this is the mapped value"}, {"The brown fox", "jumped"}, {"This is the time", "for all good things"}, - }) SMap_emplace(&smap, c_pair(v)); + }) SMap_emplace(&smap, c_pair(i.ref)); c_forpair (i, j, SMap, smap) printf(" (%s: %s)\n", cstr_str(_.i), cstr_str(_.j)); diff --git a/examples/person_arc.c b/examples/person_arc.c index bddf7bd6..cd8d1f87 100644 --- a/examples/person_arc.c +++ b/examples/person_arc.c @@ -54,8 +54,8 @@ int main() Persons_push_back(&vec, PSPtr_make(Person_new("Audrey", "Home"))); // Clone/share p and q to the vector - c_forarray (PSPtr, v, {p, q}) - Persons_push_back(&vec, PSPtr_clone(*v)); + c_forlist (i, PSPtr, {p, q}) + Persons_push_back(&vec, PSPtr_clone(*i.ref)); c_foreach (i, Persons, vec) printf("%s %s\n", cstr_str(&i.ref->get->name), cstr_str(&i.ref->get->last)); diff --git a/examples/phonebook.c b/examples/phonebook.c index 1455c978..825ef61d 100644 --- a/examples/phonebook.c +++ b/examples/phonebook.c @@ -39,8 +39,8 @@ void print_phone_book(cmap_str phone_book) int main(int argc, char **argv) { c_auto (cset_str, names) { - c_forarray_p (const char*, v, {"Hello", "Cool", "True"}) - cset_str_emplace(&names, *v); + c_forlist (i, const char*, {"Hello", "Cool", "True"}) + cset_str_emplace(&names, *i.ref); c_foreach (i, cset_str, names) printf("%s ", cstr_str(i.ref)); @@ -48,12 +48,12 @@ int main(int argc, char **argv) } c_auto (cmap_str, phone_book) { - c_forarray (cmap_str_raw, v, { + c_forlist (i, cmap_str_raw, { {"Lilia Friedman", "(892) 670-4739"}, {"Tariq Beltran", "(489) 600-7575"}, {"Laiba Juarez", "(303) 885-5692"}, {"Elliott Mooney", "(945) 616-4482"}, - }) cmap_str_emplace(&phone_book, c_pair(v)); + }) cmap_str_emplace(&phone_book, c_pair(i.ref)); printf("Phone book:\n"); print_phone_book(phone_book); diff --git a/examples/priority.c b/examples/priority.c index b8766a77..d801c118 100644 --- a/examples/priority.c +++ b/examples/priority.c @@ -20,8 +20,8 @@ int main() { cpque_i_push(&heap, stc64_uniform(&rng, &dist)); // push some negative numbers too. - c_forarray (int, v, {-231, -32, -873, -4, -343}) - cpque_i_push(&heap, *v); + c_forlist (i, int, {-231, -32, -873, -4, -343}) + cpque_i_push(&heap, *i.ref); c_forrange (N) cpque_i_push(&heap, stc64_uniform(&rng, &dist)); diff --git a/examples/shape.c b/examples/shape.c index e72c8b7d..a17208ef 100644 --- a/examples/shape.c +++ b/examples/shape.c @@ -143,11 +143,11 @@ int main(void) Polygon* pol1 = c_new(Polygon, Polygon_init()); Polygon* pol2 = c_new(Polygon, Polygon_init()); - c_forarray (Point, p, {{50, 72}, {123, 73}, {127, 201}, {828, 333}}) - Polygon_addPoint(pol1, *p); + c_forlist (i, Point, {{50, 72}, {123, 73}, {127, 201}, {828, 333}}) + Polygon_addPoint(pol1, *i.ref); - c_forarray (Point, p, {{5, 7}, {12, 7}, {12, 20}, {82, 33}, {17, 56}}) - Polygon_addPoint(pol2, *p); + c_forlist (i, Point, {{5, 7}, {12, 7}, {12, 20}, {82, 33}, {17, 56}}) + Polygon_addPoint(pol2, *i.ref); Shapes_push(&shapes, &tri1->shape); Shapes_push(&shapes, &pol1->shape); diff --git a/examples/sidebyside.cpp b/examples/sidebyside.cpp index 282beefb..2578c120 100644 --- a/examples/sidebyside.cpp +++ b/examples/sidebyside.cpp @@ -47,8 +47,8 @@ int main() { c_auto (cmap_si, food) { - c_forarray (cmap_si_raw, v, {{"burger", 5}, {"pizza", 12}, {"steak", 15}}) - cmap_si_emplace(&food, c_pair(v)); + c_forlist (i, cmap_si_raw, {{"burger", 5}, {"pizza", 12}, {"steak", 15}}) + cmap_si_emplace(&food, c_pair(i.ref)); c_foreach (i, cmap_si, food) printf("%s, %d\n", cstr_str(&i.ref->first), i.ref->second); diff --git a/examples/words.c b/examples/words.c index 888f7abb..097447aa 100644 --- a/examples/words.c +++ b/examples/words.c @@ -13,10 +13,10 @@ int main1() c_auto (cvec_str, words) c_auto (cmap_str, word_map) { - c_forarray_p (const char*, v, { + c_forlist (i, const char*, { "this", "sentence", "is", "not", "a", "sentence", "this", "sentence", "is", "a", "hoax" - }) cvec_str_emplace_back(&words, *v); + }) cvec_str_emplace_back(&words, *i.ref); c_foreach (w, cvec_str, words) { cmap_str_emplace(&word_map, cstr_str(w.ref), 0).ref->second += 1; |
