diff options
| author | Tyge Løvset <[email protected]> | 2021-01-09 23:55:42 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-01-09 23:55:42 +0100 |
| commit | f504699fb346eeb37b2ea2afe493566a26be7f4e (patch) | |
| tree | 037a22aa785f8a4a977e2546a89cd3eccd38f726 /docs | |
| parent | 0b64431209cb7acf86f4db055e69e23b7a9d8ef6 (diff) | |
| download | STC-modified-f504699fb346eeb37b2ea2afe493566a26be7f4e.tar.gz STC-modified-f504699fb346eeb37b2ea2afe493566a26be7f4e.zip | |
Added cmap benchmark and external picobenchmark.hpp
Updated cstr.h
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/cmap_api.md | 3 | ||||
| -rw-r--r-- | docs/cset_api.md | 47 |
2 files changed, 27 insertions, 23 deletions
diff --git a/docs/cmap_api.md b/docs/cmap_api.md index ee20793e..5e0a9fa3 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -134,8 +134,7 @@ using_cmap_str(); int main() { // Create an unordered_map of three strings (that map to strings) - cmap_str u = cmap_inits; - c_push_items(&u, cmap_str, { + c_init (cmap_str, u, { {"RED", "#FF0000"}, {"GREEN", "#00FF00"}, {"BLUE", "#0000FF"} diff --git a/docs/cset_api.md b/docs/cset_api.md index 831b5cdf..6ab0fb00 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -91,31 +91,36 @@ uint32_t c_default_hash32(const void* data, size_t len); ## Example
```c
#include <stdio.h>
-#include "stc/cstr.h"
-#include "stc/cset.h"
+#include <stc/cstr.h>
+#include <stc/cset.h>
+
using_cset_str();
int main ()
{
- cset_str first = cset_inits; // empty
- cset_str second = cset_inits; c_push_items(&second, cset_str, {"red","green","blue"}); // init list
- cset_str third = cset_inits; c_push_items(&third, cset_str, {"orange","pink","yellow"}); // init list
- cset_str fourth = cset_inits;
- cset_str_emplace(&fourth, "potatoes");
- cset_str_emplace(&fourth, "milk");
- cset_str_emplace(&fourth, "flour");
-
- cset_str fifth = cset_inits;
- c_foreach (x, cset_str, second) cset_str_emplace(&fifth, x.ref->str);
- c_foreach (x, cset_str, third) cset_str_emplace(&fifth, x.ref->str);
- c_foreach (x, cset_str, fourth) cset_str_emplace(&fifth, x.ref->str);
- c_del(cset_str, &first, &second, &third, &fourth);
-
- printf("fifth contains:\n\n");
- c_foreach (x, cset_str, fifth) printf("%s\n", x.ref->str);
- cset_str_del(&fifth);
-
- return 0;
+ cset_str first = cset_inits; // empty
+ c_init (cset_str, second, {"red", "green", "blue"});
+ c_init (cset_str, third, {"orange", "pink", "yellow"});
+
+ cset_str fourth = cset_inits;
+ cset_str_emplace(&fourth, "potatoes");
+ cset_str_emplace(&fourth, "milk");
+ cset_str_emplace(&fourth, "flour");
+
+ cset_str fifth = cset_str_clone(second);
+ c_foreach (i, cset_str, third)
+ cset_str_insert(&fifth, cset_str_value_clone(*i.ref));
+ c_foreach (i, cset_str, fourth)
+ cset_str_emplace(&fifth, i.ref->str);
+
+ c_del(cset_str, &first, &second, &third, &fourth);
+
+ printf("fifth contains:\n\n");
+ c_foreach (i, cset_str, fifth)
+ printf("%s\n", i.ref->str);
+
+ cset_str_del(&fifth);
+ return 0;
}
```
Output:
|
