diff options
| author | Tyge Løvset <[email protected]> | 2022-05-24 11:32:12 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-05-24 11:32:12 +0200 |
| commit | 966100106830f990bc3e1b40a5b5c39b64d5e9b0 (patch) | |
| tree | 3704a5317fedd54f86a95163c6f498c27f6f209f /docs/cmap_api.md | |
| parent | 99bfc38c2517f1ee20db3d9553be177ae6c960c6 (diff) | |
| download | STC-modified-966100106830f990bc3e1b40a5b5c39b64d5e9b0.tar.gz STC-modified-966100106830f990bc3e1b40a5b5c39b64d5e9b0.zip | |
Changed c_forpair(k, v, Map, map) so that k and v are pointers instead of values. This to make it consistent with c_foreach, c_apply, c_apply_arr.
Diffstat (limited to 'docs/cmap_api.md')
| -rw-r--r-- | docs/cmap_api.md | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/docs/cmap_api.md b/docs/cmap_api.md index 02052847..58d33534 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -217,7 +217,7 @@ int main() cmap_vi_insert(&vecs, (Vec3i){100, 100, 100}, 4); c_forpair (vec, num, cmap_vi, vecs) - printf("{ %3d, %3d, %3d }: %d\n", _.vec.x, _.vec.y, _.vec.z, _.num); + printf("{ %3d, %3d, %3d }: %d\n", _.vec->x, _.vec->y, _.vec->z, *_.num); } } ``` @@ -250,7 +250,7 @@ int main() cmap_iv_insert(&vecs, 4, (Vec3i){100, 100, 100}); c_forpair (num, vec, cmap_iv, vecs) - printf("%d: { %3d, %3d, %3d }\n", _.num, _.vec.x, _.vec.y, _.vec.z); + printf("%d: { %3d, %3d, %3d }\n", *_.num, _.vec->x, _.vec->y, _.vec->z); } } ``` @@ -322,8 +322,8 @@ int main() } // Print the status of the vikings. - c_forpair (viking, hp, Vikings, vikings) { - printf("%s of %s has %d hp\n", cstr_str(&_.viking.name), cstr_str(&_.viking.country), _.hp); + c_forpair (vik, hp, Vikings, vikings) { + printf("%s of %s has %d hp\n", cstr_str(&_.vik->name), cstr_str(&_.vik->country), *_.hp); } } } @@ -406,8 +406,8 @@ int main() Vikings_value *v = Vikings_get_mut(&vikings, (RViking){"Einar", "Norway"}); if (v) v->second += 3; // add 3 hp points to Einar - c_forpair (viking, health, Vikings, vikings) { - printf("%s of %s has %d hp\n", cstr_str(&_.viking.name), cstr_str(&_.viking.country), _.health); + c_forpair (vik, health, Vikings, vikings) { + printf("%s of %s has %d hp\n", cstr_str(&_.vik->name), cstr_str(&_.vik->country), *_.health); } } } |
