diff options
| author | Tyge Løvset <[email protected]> | 2020-07-28 07:12:23 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-07-28 07:12:23 +0200 |
| commit | 3112061bd5cc45a175f230ef3458a4bc06c5c5a2 (patch) | |
| tree | 57b2b9f3f0184bdf670787dfa48feff212782f0d /examples/README.md | |
| parent | 6a0b7f1f43f408887e83fc45452dc133496227b4 (diff) | |
| download | STC-modified-3112061bd5cc45a175f230ef3458a4bc06c5c5a2.tar.gz STC-modified-3112061bd5cc45a175f230ef3458a4bc06c5c5a2.zip | |
Reverted to before lowercasing types
Diffstat (limited to 'examples/README.md')
| -rw-r--r-- | examples/README.md | 14 |
1 files changed, 7 insertions, 7 deletions
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) {
|
