diff options
| author | Tyge Løvset <[email protected]> | 2022-06-10 16:04:22 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-06-10 16:04:22 +0200 |
| commit | d0ce3effae99478bd593011795b4184d4fddaed4 (patch) | |
| tree | 33920f2d3927eabc103cd4f4c6d2e5e6c676223f /examples/mapmap.c | |
| parent | ff29ab1ec7fd199fd0e9d0bd0884c1905dd0c1c1 (diff) | |
| download | STC-modified-d0ce3effae99478bd593011795b4184d4fddaed4.tar.gz STC-modified-d0ce3effae99478bd593011795b4184d4fddaed4.zip | |
Small simplifications in cmap.h
Diffstat (limited to 'examples/mapmap.c')
| -rw-r--r-- | examples/mapmap.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/examples/mapmap.c b/examples/mapmap.c index 2ea8fa61..7cdc2ba0 100644 --- a/examples/mapmap.c +++ b/examples/mapmap.c @@ -1,11 +1,15 @@ -// unordered_map<string, unordered_map<string, string>>: +// create a structure like: std::map<std::string, std::map<std::string, std::string>>: + #include <stc/cstr.h> + +// People: std::map<std::string, std::string> #define i_type People #define i_key_str #define i_val_str #define i_keydrop(p) (printf("kdrop: %s\n", cstr_str(p)), cstr_drop(p)) // override #include <stc/csmap.h> +// Departments: std::map<std::string, People> #define i_type Departments #define i_key_str #define i_val_bind People @@ -16,14 +20,6 @@ // #define i_valdrop People_drop #include <stc/csmap.h> -#define i_type Stack -#define i_val_bind People_value -// Shorthand for: -// #define i_val People_value (pair of cstr) -// #define i_cmp People_value_cmp -// #define i_valclone People_value_clone -// #define i_valdrop People_value_drop -#include <stc/cvec.h> void add(Departments* deps, const char* name, const char* email, const char* dep) { @@ -63,10 +59,10 @@ int main(void) printf("%s: %s - %s\n", cstr_str(&i.ref->first), cstr_str(_.name), cstr_str(_.email)); puts(""); - printf("found: %d\n", contains(&map, "Nick Denton")); - printf("found: %d\n", contains(&map, "Patrick Dust")); - printf("found: %d\n", contains(&map, "Dennis Kay")); - printf("found: %d\n", contains(&map, "Serena Bath")); + printf("found Nick Denton: %d\n", contains(&map, "Nick Denton")); + printf("found Patrick Dust: %d\n", contains(&map, "Patrick Dust")); + printf("found Dennis Kay: %d\n", contains(&map, "Dennis Kay")); + printf("found Serena Bath: %d\n", contains(&map, "Serena Bath")); puts("Done"); } } |
