summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-05-24 11:32:12 +0200
committerTyge Løvset <[email protected]>2022-05-24 11:32:12 +0200
commit966100106830f990bc3e1b40a5b5c39b64d5e9b0 (patch)
tree3704a5317fedd54f86a95163c6f498c27f6f209f /docs
parent99bfc38c2517f1ee20db3d9553be177ae6c960c6 (diff)
downloadSTC-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')
-rw-r--r--docs/carc_api.md4
-rw-r--r--docs/ccommon_api.md2
-rw-r--r--docs/cmap_api.md12
3 files changed, 9 insertions, 9 deletions
diff --git a/docs/carc_api.md b/docs/carc_api.md
index 52809165..d0d90300 100644
--- a/docs/carc_api.md
+++ b/docs/carc_api.md
@@ -135,14 +135,14 @@ int main()
puts("STACKS");
c_foreach (i, Stack, stack) {
c_forpair (name, year, Map, *i.ref->get)
- printf(" %s:%d", cstr_str(&_.name), _.year);
+ printf(" %s:%d", cstr_str(_.name), *_.year);
puts("");
}
puts("LIST");
c_foreach (i, List, list) {
c_forpair (name, year, Map, *i.ref->get)
- printf(" %s:%d", cstr_str(&_.name), _.year);
+ printf(" %s:%d", cstr_str(_.name), *_.year);
puts("");
}
}
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 249f2523..9d2baea6 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -141,7 +141,7 @@ c_foreach (i, csmap_ii, it, csmap_ii_end(&map))
// out: 7 12 23
c_forpair (id, count, csmap_ii, map)
- printf(" (%d %d)", _.id, _.count);
+ printf(" (%d %d)", *_.id, *_.count);
// out: (3 2) (5 4) (7 3) (12 5) (23 1)
```
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);
}
}
}