summaryrefslogtreecommitdiffhomepage
path: root/examples/mapmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/mapmap.c')
-rw-r--r--examples/mapmap.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/mapmap.c b/examples/mapmap.c
new file mode 100644
index 00000000..77c71fe9
--- /dev/null
+++ b/examples/mapmap.c
@@ -0,0 +1,20 @@
+
+#include <stdio.h>
+#include <stc/chash.h>
+
+static void test_destr(int* x) {
+ printf("destroy int: %d\n", *x);
+}
+
+declare_CMap(ii, int, int, test_destr);
+declare_CMap(im, int, CMap_ii, cmap_ii_destroy);
+
+int main(void) {
+ CMap_im m = cmap_init;
+ CMap_ii x = cmap_init;
+ cmap_ii_put(&cmap_im_put(&m, 100, x)->value, 200, 300);
+ cmap_ii_put(&cmap_im_get(&m, 100)->value, 200, 400); // update
+ cmap_ii_put(&cmap_im_put(&m, 110, x)->value, 200, 500);
+
+ cmap_im_destroy(&m);
+} \ No newline at end of file