diff options
| author | Tyge Løvset <[email protected]> | 2020-03-14 00:15:42 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-03-14 00:15:42 +0100 |
| commit | 7186ae150819a54173e32df8515166bf351fb02f (patch) | |
| tree | fb8ae5af9248d9f83906e933bb7066f199d4cc4e | |
| parent | 89c88324212b72d01722609b58a7f19f6d494482 (diff) | |
| download | STC-modified-7186ae150819a54173e32df8515166bf351fb02f.tar.gz STC-modified-7186ae150819a54173e32df8515166bf351fb02f.zip | |
Update EXAMPLE.md
| -rw-r--r-- | EXAMPLE.md | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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 <clib/CMap.h> -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. |
