diff options
| author | Tyge Løvset <[email protected]> | 2021-05-21 16:02:37 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-05-21 16:02:37 +0200 |
| commit | 6f78caf518a151bfe4a658245bae21df30ed5011 (patch) | |
| tree | 46fb6055df31511d08beec797e425bbc1ebb443d | |
| parent | 77e61266489a2e69693f714b601f3824d16ae1ba (diff) | |
| parent | 29f36f157dbd25afd5da5876d2a37035c2f83c0c (diff) | |
| download | STC-modified-6f78caf518a151bfe4a658245bae21df30ed5011.tar.gz STC-modified-6f78caf518a151bfe4a658245bae21df30ed5011.zip | |
Merge branch 'master' of https://github.com/tylo-work/C99Containers into master
| -rw-r--r-- | docs/csview_api.md | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/docs/csview_api.md b/docs/csview_api.md index 0a4595e0..525de2f1 100644 --- a/docs/csview_api.md +++ b/docs/csview_api.md @@ -115,36 +115,17 @@ using_cset_sv() // cmap<cstr, int> with csview as convertion type using_cmap_svkey(si, int); -// cvec<cstr> with csview as convertion type -using_cvec_sv(); int main() { csview text = c_lit("The length of this literal is evaluated at compile time and stored in csview text."); printf("%s\nLength: %zu\n\n", text.str, text.size); - // cvec of cstr elements, using csview as "emplace" type - c_var (cvec_sv, vec, { // defines vec with 3 cstr elements. - c_lit("Element 1"), // will be converted to cstr. - c_lit("Element 2"), - c_lit("Element 3") - }); - c_defer (cvec_sv_del(&vec)) // defer destruction to end of block. - { - // push constructed cstr directly - cvec_sv_push_back(&vec, cstr_lit("Second last element")); - // emplace constructs cstr from a csview - cvec_sv_emplace_back(&vec, c_lit("Last element")); - - c_foreach (i, cvec_sv, vec) - printf("%s\n", i.ref->str); - } - c_withvar (cmap_si, map) // defines map and defers destruction. { cmap_si_emplace(&map, c_lit("hello"), 100); cmap_si_emplace(&map, c_lit("world"), 200); - cmap_si_emplace(&map, c_lit("gone mad"), 300); + cmap_si_emplace(&map, c_lit("hello"), 300); // already in map, ignored // Efficient lookup: no string allocation or strlen() takes place: cmap_si_value_t* v = cmap_si_get(&map, c_lit("world")); @@ -157,12 +138,6 @@ Output: A long and winded literal string Length: 32 -Great -Fantastic -Sensational -Second last element -Last element - world: 200 ``` |
