From 3112061bd5cc45a175f230ef3458a4bc06c5c5a2 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 28 Jul 2020 07:12:23 +0200 Subject: Reverted to before lowercasing types --- examples/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'examples/README.md') diff --git a/examples/README.md b/examples/README.md index e222f8bc..4d43a7d2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,7 +6,7 @@ Contains various examples and benchmarks. advanced.c Example ------------------ -This demonstrates how to customize hash **cmap** with a user-defined key-type. You need to define two things: +This demonstrates how to customize hash **CMap** with a user-defined key-type. You need to define two things: 1. A hash function; calculates the hash value given an object of the key-type. @@ -40,8 +40,8 @@ int vikingvw_equals(const VikingVw* x, const VikingVw* y) { And the Viking data struct: ``` typedef struct Viking { - cstr_t name; - cstr_t country; + CStr name; + CStr country; } Viking; @@ -58,9 +58,9 @@ Viking viking_fromVw(VikingVw vw) { } ``` -With this in place, we use the full declare_cmap() macro to define {Viking -> int} hash map type: +With this in place, we use the full declare_CMap() macro to define {Viking -> int} hash map type: ``` -declare_cmap(vk, Viking, int, c_defaultDestroy, vikingvw_equals, vikingvw_hash, +declare_CMap(vk, Viking, int, c_defaultDestroy, vikingvw_equals, vikingvw_hash, viking_destroy, VikingVw, viking_getVw, viking_fromVw); ``` CMap_vk uses vikingvw_hash() for hash value calculations, and vikingvw_equals() for equality test. cmap_vk_destroy() will free all memory allocated for Viking keys and the hash table values. @@ -68,13 +68,13 @@ Finally, the demo: ``` int main() { - cmap_vk vikings = cmap_init; + CMap_vk vikings = cmap_init; // emplace constructs the keys cmap_vk_put(&vikings, (VikingVw) {"Einar", "Norway"}, 20); cmap_vk_put(&vikings, (VikingVw) {"Olaf", "Denmark"}, 24); cmap_vk_put(&vikings, (VikingVw) {"Harald", "Iceland"}, 12); - cmapentry_vk* e = cmap_vk_get(&vikings, (VikingVw) {"Einar", "Norway"}); + CMapEntry_vk* e = cmap_vk_get(&vikings, (VikingVw) {"Einar", "Norway"}); e->value += 5; // update c_foreach (k, cmap_vk, vikings) { -- cgit v1.2.3