summaryrefslogtreecommitdiffhomepage
path: root/examples/README.md
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-07-31 09:49:44 +0200
committerTyge Løvset <[email protected]>2020-07-31 09:49:44 +0200
commit1a1e5fb89e70bcff7fbd5be3d52149319ce2b7ae (patch)
treee7ecec0955082cff938277d377758d83474b8f72 /examples/README.md
parent4a91d7efe31db2d78cc87efafa39c4a2190ecf5a (diff)
downloadSTC-modified-1a1e5fb89e70bcff7fbd5be3d52149319ce2b7ae.tar.gz
STC-modified-1a1e5fb89e70bcff7fbd5be3d52149319ce2b7ae.zip
Updated README.md Viking example.
Diffstat (limited to 'examples/README.md')
-rw-r--r--examples/README.md10
1 files changed, 3 insertions, 7 deletions
diff --git a/examples/README.md b/examples/README.md
index f3691b97..1bf38f58 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,19 +1,15 @@
Examples
========
-Contains various examples and benchmarks.
+This folder contains various examples and benchmarks.
-advanced.c Example
+Custom key 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 **cmap** with a user-defined key-type. When your key type consists of several members, you will usually have the hash function calculate hash values for the individual members, and then somehow combine them into one hash value for the entire object. If your key-type stores dynamic memory (e.g. cstr_t, as we will use), it is recommended to define a "view/raw"-struct of the your data first. In addition, you must define two functions:
1. A hash function; calculates the hash value given an object of the key-type.
2. A comparison function for equality;
-
-When your key type consists of several members, you will usually have the hash function calculate hash values for the individual members, and then somehow combine them into one hash value for the entire object.
-If your key-type stores dynamic memory (e.g. CStr as we will use), it is smart to define a plain-old-data "view" of the your key struct first:
```
#include <stdio.h>
#include <stc/cmap.h>