From 2da0a2c2d5fa154ea0151156b4e35a1ac8d50bc4 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 22 Feb 2021 18:53:09 +0100 Subject: Small changes. Added back csmap/cmap put() but now with Key,Mapped args (not RawKey,RawMapped). --- examples/inits.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'examples') diff --git a/examples/inits.c b/examples/inits.c index edcb4336..0c716fd1 100644 --- a/examples/inits.c +++ b/examples/inits.c @@ -5,8 +5,8 @@ #include #include -using_cmap(id, int, cstr, c_default_equals, c_default_hash, cstr_del, c_no_clone); // Map of int -> cstr -using_cmap_strkey(cnt, int); +using_cmap_strval(id, int); // Map of int => cstr +using_cmap_strkey(cnt, int); // Map of cstr => int typedef struct {int x, y;} ipair_t; inline static int ipair_compare(const ipair_t* a, const ipair_t* b) { @@ -46,7 +46,7 @@ int main(void) int year = 2020; cmap_id idnames = cmap_id_init(); - cmap_id_insert(&idnames, 100, cstr_from("Hello")); + cmap_id_emplace(&idnames, 100, "Hello"); cmap_id_insert(&idnames, 110, cstr_from("World")); cmap_id_insert(&idnames, 120, cstr_from_fmt("Howdy, -%d-", year)); @@ -80,13 +80,7 @@ int main(void) // CVEC PAIR - cvec_ip pairs1 = cvec_ip_init(); - c_emplace_items(&pairs1, cvec_ip, { - {5, 6}, - {3, 4}, - {1, 2}, - {7, 8}, - }); + c_init (cvec_ip, pairs1, { {5, 6}, {3, 4}, {1, 2}, {7, 8} }); cvec_ip_sort(&pairs1); c_foreach (i, cvec_ip, pairs1) @@ -96,13 +90,7 @@ int main(void) // CLIST PAIR - clist_ip pairs2 = clist_ip_init(); - c_emplace_items(&pairs2, clist_ip, { - {5, 6}, - {3, 4}, - {1, 2}, - {7, 8}, - }); + c_init (clist_ip, pairs2, { {5, 6}, {3, 4}, {1, 2}, {7, 8} }); clist_ip_sort(&pairs2); c_foreach (i, clist_ip, pairs2) -- cgit v1.2.3