summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/arcvec_erase.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-02-08 16:16:49 +0100
committerTyge Løvset <[email protected]>2023-02-08 17:18:24 +0100
commitc4441f5fc665194fbd7a894a67a64a08c3beac42 (patch)
tree82f231b6e8fcb75625166f98aa785baaa265a3d6 /misc/examples/arcvec_erase.c
parent673dd5319a488d4b702b94dd9aeda4e497ae4fbc (diff)
downloadSTC-modified-c4441f5fc665194fbd7a894a67a64a08c3beac42.tar.gz
STC-modified-c4441f5fc665194fbd7a894a67a64a08c3beac42.zip
Changed to use lowercase flow-control macros in examples (uppercase will still be supported). Improved many examples to use c_make() to init containers.
Diffstat (limited to 'misc/examples/arcvec_erase.c')
-rw-r--r--misc/examples/arcvec_erase.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/misc/examples/arcvec_erase.c b/misc/examples/arcvec_erase.c
index 8385ed65..38f11097 100644
--- a/misc/examples/arcvec_erase.c
+++ b/misc/examples/arcvec_erase.c
@@ -15,17 +15,16 @@ void show_drop(int* x) { printf("drop: %d\n", *x); }
int main()
{
- c_AUTO (Vec, vec)
+ c_auto (Vec, vec)
{
- c_FORLIST (i, int, {2012, 1990, 2012, 2019, 2015})
- Vec_emplace(&vec, *i.ref);
+ vec = c_make(Vec, {2012, 1990, 2012, 2019, 2015});
// clone the second 2012 and push it back.
// note: cloning make sure that vec.data[2] has ref count 2.
Vec_push(&vec, Arc_clone(vec.data[2]));
printf("vec before erase :");
- c_FOREACH (i, Vec, vec)
+ c_foreach (i, Vec, vec)
printf(" %d", *i.ref->get);
printf("\nerase vec.data[2]; or first matching value depending on compare.\n");
@@ -40,12 +39,12 @@ int main()
Vec_erase_at(&vec, it);
printf("vec after erase :");
- c_FOREACH (i, Vec, vec)
+ c_foreach (i, Vec, vec)
printf(" %d", *i.ref->get);
Vec_sort(&vec);
printf("\nvec after sort :");
- c_FOREACH (i, Vec, vec)
+ c_foreach (i, Vec, vec)
printf(" %d", *i.ref->get);
puts("\nDone");