summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/advanced.c2
-rw-r--r--examples/new_sptr.c16
2 files changed, 11 insertions, 7 deletions
diff --git a/examples/advanced.c b/examples/advanced.c
index 70aef8e8..0466e0da 100644
--- a/examples/advanced.c
+++ b/examples/advanced.c
@@ -47,7 +47,7 @@ static inline VikingRaw viking_toRaw(const Viking* vk) {
int main()
{
- c_autovar (cmap_vk vikings = cmap_vk_init(), cmap_vk_del(&vikings)) {
+ c_auto (cmap_vk, vikings) {
c_apply_pair(cmap_vk, emplace, &vikings, {
{{"Einar", "Norway"}, 20},
{{"Olaf", "Denmark"}, 24},
diff --git a/examples/new_sptr.c b/examples/new_sptr.c
index 25eb6702..59512803 100644
--- a/examples/new_sptr.c
+++ b/examples/new_sptr.c
@@ -19,11 +19,12 @@ void Person_del(Person* p) {
// ...
#define i_val int
+#define i_del(x) printf("del: %d\n", *(x))
#include <stc/csptr.h>
-#define i_key_csptr csptr_int
+#define i_val_csptr csptr_int
#define i_tag iptr
-#include <stc/csset.h>
+#include <stc/cstack.h>
int main(void) {
c_autovar (csptr_person p = csptr_person_make(Person_init("John", "Smiths")), csptr_person_del(&p))
@@ -32,11 +33,14 @@ int main(void) {
printf("%s %s. uses: %u\n", q.get->name.str, q.get->last.str, *q.use_count);
}
- c_auto (csset_iptr, map) {
- csset_iptr_insert(&map, csptr_int_make(2021));
- csset_iptr_insert(&map, csptr_int_make(2033));
+ c_auto (cstack_iptr, stk) {
+ cstack_iptr_push(&stk, csptr_int_make(10));
+ cstack_iptr_push(&stk, csptr_int_make(20));
+ cstack_iptr_push(&stk, csptr_int_make(30));
+ cstack_iptr_emplace(&stk, *cstack_iptr_top(&stk));
+ cstack_iptr_emplace(&stk, *cstack_iptr_begin(&stk).ref);
- c_foreach (i, csset_iptr, map)
+ c_foreach (i, cstack_iptr, stk)
printf(" %d", *i.ref->get);
puts("");
}