From 7186ae150819a54173e32df8515166bf351fb02f Mon Sep 17 00:00:00 2001 From: Tyge Løvset <60263450+tylo-work@users.noreply.github.com> Date: Sat, 14 Mar 2020 00:15:42 +0100 Subject: Update EXAMPLE.md --- EXAMPLE.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/EXAMPLE.md b/EXAMPLE.md index 93a07cf2..c0ce9936 100644 --- a/EXAMPLE.md +++ b/EXAMPLE.md @@ -52,22 +52,22 @@ size_t key_hash(const struct Key* k, size_t ignore) { With this in place, you can instantiate a CMap with Key => CString: ``` #include -declare_CMap(mm, struct Key, CString, cstring_destroy, key_compare, key_hash, key_destroy); +declare_CMap(ex, struct Key, CString, cstring_destroy, key_compare, key_hash, key_destroy); int main() { - CMap_mm m6 = cmap_initializer; - cmap_mm_put(&m6, key_make("John", "Doe", 12), cstring_make("example")); - cmap_mm_put(&m6, key_make("Mary", "Sue", 21), cstring_make("another")); + CMap_ex m6 = cmap_initializer; + cmap_ex_put(&m6, key_make("John", "Doe", 12), cstring_make("example")); + cmap_ex_put(&m6, key_make("Mary", "Sue", 21), cstring_make("another")); // ... - c_foreach (it, cmap_mm, m6) { + c_foreach (it, cmap_ex, m6) { if (cstring_equals(it.item->key.first, "John")) printf("%s %s %d -> %s\n", it.item->key.first.str, it.item->key.second.str, it.item->key.third, it.item->value.str); } - cmap_mm_destroy(&m6); + cmap_ex_destroy(&m6); } ``` It will automatically use key_hash() as defined above for the hash value calculations, and the key_compare() for equality checks. -- cgit v1.2.3