summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2022-08-11 23:33:14 +0200
committerTyge Lovset <[email protected]>2022-08-11 23:33:14 +0200
commitf534db7ac4a993a05074868b8840a3a674ac76b4 (patch)
tree7b5d6d011f2ec3896ef97b50a05adf797551b1cb /examples
parent2526ae23267a5381f0564100b2aba73dfc367b58 (diff)
downloadSTC-modified-f534db7ac4a993a05074868b8840a3a674ac76b4.tar.gz
STC-modified-f534db7ac4a993a05074868b8840a3a674ac76b4.zip
find_if, find_in changed.
Diffstat (limited to 'examples')
-rw-r--r--examples/arc_containers.c2
-rw-r--r--examples/arcvec_erase.c7
-rw-r--r--examples/city.c9
3 files changed, 10 insertions, 8 deletions
diff --git a/examples/arc_containers.c b/examples/arc_containers.c
index e8716129..debc6617 100644
--- a/examples/arc_containers.c
+++ b/examples/arc_containers.c
@@ -53,7 +53,7 @@ int main()
// Clone (deep copy) a Map from the stack to the list
// List will contain two shared and two unshared maps.
- map = List_push_back(&list, Arc_make(Map_clone(*stack.data[1].get)))->get;
+ map = List_push_back(&list, Arc_from(Map_clone(*stack.data[1].get)))->get;
// Add one more element to the cloned map:
Map_emplace_or_assign(map, "CLONED", 2021);
diff --git a/examples/arcvec_erase.c b/examples/arcvec_erase.c
index eba77f51..b96f4278 100644
--- a/examples/arcvec_erase.c
+++ b/examples/arcvec_erase.c
@@ -20,13 +20,12 @@ int main()
{
c_auto (Vec, vec)
{
- const int v[] = {2012, 1990, 2012, 2019, 2015};
- c_forrange (i, c_arraylen(v))
- Vec_push_back(&vec, Arc_make(v[i]));
+ c_forarray (int, v, {2012, 1990, 2012, 2019, 2015})
+ Vec_emplace(&vec, *v);
// clone the second 2012 and push it back.
// note: cloning make sure that vec.data[2] has ref count 2.
- Vec_push_back(&vec, Arc_clone(vec.data[2]));
+ Vec_push(&vec, Arc_clone(vec.data[2]));
printf("vec before erase :");
c_foreach (i, Vec, vec)
diff --git a/examples/city.c b/examples/city.c
index c22693f9..0fcee341 100644
--- a/examples/city.c
+++ b/examples/city.c
@@ -58,8 +58,9 @@ int main(void)
{"Berlin", "Germany", 4.3, 23.2, 9000000},
{"London", "UK", 4.3, 23.2, 9000000},
}) {
- Cities_push(&cities, CityArc_make((City){cstr_from(c->name), cstr_from(c->country),
- c->lat, c->lon, c->pop}));
+ Cities_emplace(&cities, (City){cstr_from(c->name),
+ cstr_from(c->country),
+ c->lat, c->lon, c->pop});
}
copy = Cities_clone(cities); // share each element!
@@ -73,7 +74,9 @@ int main(void)
printf("Vec:\n");
c_foreach (c, Cities, cities)
- printf("city:%s, %d, use:%ld\n", cstr_str(&c.ref->get->name), c.ref->get->population, CityArc_use_count(*c.ref));
+ printf("city:%s, %d, use:%ld\n", cstr_str(&c.ref->get->name),
+ c.ref->get->population,
+ CityArc_use_count(*c.ref));
printf("\nMap:\n");
c_forpair (id, city, CityMap, map)