summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/new_map.c
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2023-04-12 15:55:33 -0400
committerrealtradam <[email protected]>2023-04-12 15:55:33 -0400
commit0841165881871ee01b782129be681209aeed2423 (patch)
tree8a76b61dcaab381b6b42305201ae8b6259f6b6c0 /misc/examples/new_map.c
parent554f3e8acf7855b5d6a90cc68cefb7445460b03c (diff)
parent0516aa3ae823ed9a22b2c5f776948c8447c32c31 (diff)
downloadSTC-modified-0841165881871ee01b782129be681209aeed2423.tar.gz
STC-modified-0841165881871ee01b782129be681209aeed2423.zip
Merge branch 'master' into modified
Diffstat (limited to 'misc/examples/new_map.c')
-rw-r--r--misc/examples/new_map.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/misc/examples/new_map.c b/misc/examples/new_map.c
index a4d5289c..3a4f934d 100644
--- a/misc/examples/new_map.c
+++ b/misc/examples/new_map.c
@@ -26,7 +26,7 @@ int point_cmp(const Point* a, const Point* b) {
#define i_val int
#define i_cmp point_cmp
#define i_hash c_default_hash
-#define i_opt c_is_forward
+#define i_is_forward
#define i_tag pnt
#include <stc/cmap.h>
@@ -42,33 +42,33 @@ int point_cmp(const Point* a, const Point* b) {
int main()
{
- c_auto (cmap_int, map)
- c_auto (cmap_pnt, pmap)
- c_auto (cmap_str, smap)
- c_auto (cset_str, sset)
- {
- cmap_int_insert(&map, 123, 321);
- cmap_int_insert(&map, 456, 654);
- cmap_int_insert(&map, 789, 987);
-
- pmap = c_make(cmap_pnt, {{{42, 14}, 1}, {{32, 94}, 2}, {{62, 81}, 3}});
-
- c_foreach (i, cmap_pnt, pmap)
- printf(" (%d, %d: %d)", i.ref->first.x, i.ref->first.y, i.ref->second);
- puts("");
-
- smap = c_make(cmap_str, {
- {"Hello, friend", "long time no see"},
- {"So long", "see you around"},
- });
-
- sset = c_make(cset_str, {
- "Hello, friend",
- "Nice to see you again",
- "So long",
- });
-
- c_foreach (i, cset_str, sset)
- printf(" %s\n", cstr_str(i.ref));
- }
+ cmap_pnt pmap = c_make(cmap_pnt, {{{42, 14}, 1}, {{32, 94}, 2}, {{62, 81}, 3}});
+
+ c_foreach (i, cmap_pnt, pmap)
+ printf(" (%d, %d: %d)", i.ref->first.x, i.ref->first.y, i.ref->second);
+ puts("");
+
+ cmap_str smap = c_make(cmap_str, {
+ {"Hello, friend", "long time no see"},
+ {"So long", "see you around"},
+ });
+
+ cset_str sset = c_make(cset_str, {
+ "Hello, friend",
+ "Nice to see you again",
+ "So long",
+ });
+
+ cmap_int map = {0};
+ cmap_int_insert(&map, 123, 321);
+ cmap_int_insert(&map, 456, 654);
+ cmap_int_insert(&map, 789, 987);
+
+ c_foreach (i, cset_str, sset)
+ printf(" %s\n", cstr_str(i.ref));
+
+ cmap_int_drop(&map);
+ cset_str_drop(&sset);
+ cmap_str_drop(&smap);
+ cmap_pnt_drop(&pmap);
}