Skip to content

Commit 01f2a20

Browse files
committed
2nd try to please Jekyll...
1 parent f02324f commit 01f2a20

6 files changed

+42
-24
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ int main(void)
295295
This example uses four different container types:
296296

297297
[ [Run this code](https://godbolt.org/z/n1z16bdTr) ]
298+
<!--{%raw%}-->
298299
```c++
299300
#include <stdio.h>
300301

@@ -329,8 +330,8 @@ int main(void)
329330
){
330331
enum{N = 5};
331332
int nums[N] = {10, 20, 30, 40, 50};
332-
struct Point pts[N] = { {10, 1}, {20, 2}, {30, 3}, {40, 4}, {50, 5}};
333-
int pairs[N][2] = { {20, 2}, {10, 1}, {30, 3}, {40, 4}, {50, 5}};
333+
struct Point pts[N] = {{10, 1}, {20, 2}, {30, 3}, {40, 4}, {50, 5}};
334+
int pairs[N][2] = {{20, 2}, {10, 1}, {30, 3}, {40, 4}, {50, 5}};
334335

335336
// Add some elements to each container
336337
for (int i = 0; i < N; ++i) {
@@ -375,7 +376,7 @@ int main(void)
375376
}
376377
}
377378
```
378-
379+
<!--{%endraw%}-->
379380
Output
380381
```
381382
Found: 20, (20, 2), 20, [20: 2]

docs/algorithm_api.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ descriptive and reduces chances of making mistakes. It is generally easier to re
2222
| `c_foreach_reverse (it, ctype, it1, it2)`| Iteratate range [it1, it2) elements in reverse. |
2323
| `c_foreach_n (it, ctype, container, n)`| Iteratate `n` first elements. Index variable is `{it}_index`. |
2424
| `c_foreach_kv (key, val, ctype, container)` | Iterate maps with "structured binding" |
25-
25+
<!--{%raw%}-->
2626
```c++
2727
#define i_type IMap, int, int
2828
#include "stc/smap.h"
2929
// ...
30-
IMap map = c_make(IMap, { {23,1}, {3,2}, {7,3}, {5,4}, {12,5}});
30+
IMap map = c_make(IMap, {{23,1}, {3,2}, {7,3}, {5,4}, {12,5}});
3131

3232
c_foreach (i, IMap, map)
3333
printf(" %d", i.ref->first);
@@ -52,25 +52,28 @@ c_foreach_n (i, IMap, map, 3)
5252
c_foreach_kv (id, count, IMap, map)
5353
printf(" (%d %d)", *id, *count);
5454
```
55+
<!--{%endraw%}-->
5556
</details>
5657
<details>
5758
<summary><b>c_foritems</b> - Literal list iteration</summary>
5859
5960
### c_foritems
6061
Iterate compound literal array elements. In addition to `i.ref`, you can access `i.index` and `i.size`.
62+
<!--{%raw%}-->
6163
```c++
6264
// apply multiple push_backs
6365
c_foritems (i, int, {4, 5, 6, 7})
6466
list_i_push_back(&lst, *i.ref);
6567
6668
// insert in existing map
67-
c_foritems (i, hmap_ii_value, { {4, 5}, {6, 7}})
69+
c_foritems (i, hmap_ii_value, {{4, 5}, {6, 7}})
6870
hmap_ii_insert(&map, i.ref->first, i.ref->second);
6971
7072
// string literals pushed to a stack of cstr elements:
7173
c_foritems (i, const char*, {"Hello", "crazy", "world"})
7274
stack_cstr_emplace(&stk, *i.ref);
7375
```
76+
<!--{%endraw%}-->
7477
</details>
7578

7679
## Integer range loops
@@ -405,6 +408,7 @@ These work on any container. *c_make()* may also be used for **cspan** views.
405408
- **c_drop** - drop (destroy) multiple containers of the same type
406409
407410
[ [Run this code](https://godbolt.org/z/K9Y5EMGxM) ]
411+
<!--{%raw%}-->
408412
```c++
409413
#include <stdio.h>
410414
#define i_type Vec, int
@@ -424,10 +428,10 @@ c_func (split_map,(Map map), ->, struct {Vec keys, values;}) {
424428
425429
int main(void) {
426430
Vec vec = c_make(Vec, {1, 2, 3, 4, 5, 6});
427-
Map map = c_make(Map, { {1, 2}, {3, 4}, {5, 6}});
431+
Map map = c_make(Map, {{1, 2}, {3, 4}, {5, 6}});
428432
429433
c_push(Vec, &vec, {7, 8, 9, 10, 11, 12});
430-
c_push(Map, &map, { {7, 8}, {9, 10}, {11, 12}});
434+
c_push(Map, &map, {{7, 8}, {9, 10}, {11, 12}});
431435
432436
c_foreach (i, Vec, vec)
433437
printf("%d ", *i.ref);
@@ -447,6 +451,7 @@ int main(void) {
447451
c_drop(Map, &map);
448452
}
449453
```
454+
<!--{%endraw%}-->
450455
</details>
451456
<details>
452457
<summary><b>c_find, c_copy, c_erase</b> - Container operations with custom predicate</summary>
@@ -474,6 +479,7 @@ Copy linearily in containers using a predicate. `value` is a pointer to each ele
474479
Erase linearily in containers using a predicate. `value` is a pointer to each element in predicate.
475480
- `c_erase_if(CntType, cnt_ptr, pred)`. Use with **list**, **hmap**, **hset**, **smap**, and **sset**.
476481
- `c_eraseremove_if(CntType, cnt_ptr, pred)`. Use with **stack**, **vec**, **deque**, and **queue** only.
482+
<!--{%raw%}-->
477483
```c++
478484
#include <stdio.h>
479485
#include "stc/cstr.h"
@@ -521,7 +527,7 @@ int main(void)
521527
puts("");
522528

523529
// Search a sorted map from it1, for the first string containing "hello" and erase it:
524-
Map map = c_make(Map, { {"yes",1}, {"no",2}, {"say hello from me",3}, {"goodbye",4}});
530+
Map map = c_make(Map, {{"yes",1}, {"no",2}, {"say hello from me",3}, {"goodbye",4}});
525531
Map_iter res, it1 = Map_begin(&map);
526532

527533
c_find_if(Map, it1, Map_end(&map), &res, cstr_contains(&value->first, "hello"));
@@ -536,6 +542,7 @@ int main(void)
536542
Map_drop(&map);
537543
}
538544
```
545+
<!--{%endraw%}-->
539546
</details>
540547
<details>
541548
<summary><b>c_all_of, c_any_of, c_none_of</b> - Boolean container operations</summary>

docs/arc_api.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ bool arc_X_value_eq(const i_key* x, const i_key* y);
9090
## Example
9191

9292
[ [Run this code](https://godbolt.org/z/bjrf47qbv) ]
93+
<!--{%raw%}-->
9394
```c++
9495
// Create two stacks with arcs to maps.
9596
// Demonstrate sharing and cloning of maps.
@@ -117,15 +118,15 @@ int main(void)
117118

118119
// POPULATE s1 with shared pointers to Map:
119120
map = Stack_push(&s1, Arc_from(Map_init()))->get; // push empty map to s1.
120-
c_push(Map, map, { {"Joey", 1990}, {"Mary", 1995},
121+
c_push(Map, map, {{"Joey", 1990}, {"Mary", 1995},
121122
{"Mary", 1996}, {"Joanna", 1992}});
122123

123124
map = Stack_emplace(&s1, Map_init())->get; // emplace will make the Arc
124-
c_push(Map, map, { {"Rosanna", 2001}, {"Brad", 1999}, {"Jack", 1980}});
125+
c_push(Map, map, {{"Rosanna", 2001}, {"Brad", 1999}, {"Jack", 1980}});
125126

126127
// POPULATE s2:
127128
map = Stack_emplace(&s2, Map_init())->get;
128-
c_push(Map, map, { {"Steve", 1979}, {"Rick", 1974}, {"Tracy", 2003}});
129+
c_push(Map, map, {{"Steve", 1979}, {"Rick", 1974}, {"Tracy", 2003}});
129130

130131

131132
// Share Arc 1 from s1 with s2 by cloning(=sharing):
@@ -142,3 +143,4 @@ int main(void)
142143
c_drop(Stack, &s1, &s2);
143144
}
144145
```
146+
<!--{%endraw%}-->

docs/coroutine_api.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ current task. Because the "call-tree" is fixed, the coroutine frames to be calle
330330
which is very fast.
331331
332332
[ [Run this code](https://godbolt.org/z/z1WWPhsan) ]
333+
<!--{%raw%}-->
333334
```c++
334335
#include <stdio.h>
335336
#include "stc/coroutine.h"
@@ -410,17 +411,18 @@ int start(cco_task* self, cco_runtime* rt) {
410411
int main(void)
411412
{
412413
Subtasks env = {
413-
{ {taskA}, 42},
414-
{ {taskB}, 3.1415},
415-
{ {taskC}, 1.2f, 3.4f},
414+
{{taskA}, 42},
415+
{{taskB}, 3.1415},
416+
{{taskC}, 1.2f, 3.4f},
416417
};
417-
cco_task task = { {start}};
418+
cco_task task = {{start}};
418419
419420
int count = 0;
420421
cco_run_task(&task, &env) { ++count; }
421422
printf("resumes: %d\n", count);
422423
}
423424
```
425+
<!--{%endraw%}-->
424426
</details>
425427

426428
#### Stackful coroutines allocated on the heap
@@ -435,6 +437,7 @@ call/await:
435437
<summary>Implementation of stackful coroutines</summary>
436438

437439
[ [Run this code](https://godbolt.org/z/TbWYsbaaq) ]
440+
<!--{%raw%}-->
438441
```c++
439442
#include <stdio.h>
440443
#include "stc/coroutine.h"
@@ -471,7 +474,7 @@ int taskC(struct TaskC* self, cco_runtime* rt) {
471474
int taskB(struct TaskB* self, cco_runtime* rt) {
472475
cco_routine (self) {
473476
printf("TaskB start: %g\n", self->d);
474-
cco_await_task(c_new(struct TaskC, { {taskC}, 1.2f, 3.4f}), rt);
477+
cco_await_task(c_new(struct TaskC, {{taskC}, 1.2f, 3.4f}), rt);
475478
puts("TaskB work");
476479
((Result *)rt->env)->value += self->d;
477480

@@ -485,7 +488,7 @@ int taskB(struct TaskB* self, cco_runtime* rt) {
485488
int taskA(struct TaskA* self, cco_runtime* rt) {
486489
cco_routine (self) {
487490
printf("TaskA start: %d\n", self->a);
488-
cco_await_task(c_new(struct TaskB, { {taskB}, 3.1415}), rt);
491+
cco_await_task(c_new(struct TaskB, {{taskB}, 3.1415}), rt);
489492
puts("TaskA work");
490493
((Result *)rt->env)->value += self->a; // final return value;
491494

@@ -505,7 +508,7 @@ int taskA(struct TaskA* self, cco_runtime* rt) {
505508
int start(cco_task* self, cco_runtime* rt) {
506509
cco_routine (self) {
507510
puts("start");
508-
cco_await_task(c_new(struct TaskA, { {taskA}, 42}), rt);
511+
cco_await_task(c_new(struct TaskA, {{taskA}, 42}), rt);
509512

510513
cco_finally:
511514
puts("done");
@@ -516,7 +519,7 @@ int start(cco_task* self, cco_runtime* rt) {
516519

517520
int main(void)
518521
{
519-
cco_task* task = c_new(cco_task, { {start}});
522+
cco_task* task = c_new(cco_task, {{start}});
520523

521524
int count = 0;
522525
Result result = {0};
@@ -526,6 +529,7 @@ int main(void)
526529
printf("resumes: %d\n", count);
527530
}
528531
```
532+
<!--{%endraw%}-->
529533
</details>
530534
531535
----

docs/hmap_api.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ In this example we use keyraw feature to make it simpler to use and avoids the c
286286
entirely when doing lookup.
287287

288288
[ [Run this code](https://godbolt.org/z/Yx1Ybhxqv) ]
289+
<!--{%raw%}-->
289290
```c++
290291
#include "stc/cstr.h"
291292

@@ -340,9 +341,9 @@ Viking_raw Viking_toraw(const Viking* vp) {
340341
int main(void)
341342
{
342343
Vikings vikings = c_make(Vikings, {
343-
{ {"Einar", "Norway"}, 25},
344-
{ {"Olaf", "Denmark"}, 24},
345-
{ {"Harald", "Iceland"}, 12},
344+
{{"Einar", "Norway"}, 25},
345+
{{"Olaf", "Denmark"}, 24},
346+
{{"Harald", "Iceland"}, 12},
346347
});
347348

348349
// Now lookup is using Viking_raw, not Viking:
@@ -355,3 +356,4 @@ int main(void)
355356
Vikings_drop(&vikings);
356357
}
357358
```
359+
<!--{%endraw%}-->

docs/smap_api.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ int main(void)
192192
This example uses a smap with cstr as mapped value. Note the `i_valpro` usage.
193193
194194
[ [Run this code](https://godbolt.org/z/M397fG7fM) ]
195+
<!--{%raw%}-->
195196
```c++
196197
#include "stc/cstr.h"
197198
@@ -203,7 +204,7 @@ This example uses a smap with cstr as mapped value. Note the `i_valpro` usage.
203204
int main(void)
204205
{
205206
uint32_t col = 0xcc7744ff;
206-
IdMap idnames = c_make(IdMap, { {100, "Red"}, {110, "Blue"}});
207+
IdMap idnames = c_make(IdMap, {{100, "Red"}, {110, "Blue"}});
207208
208209
// Assign/overwrite an existing mapped value with a const char*
209210
IdMap_emplace_or_assign(&idnames, 110, "White");
@@ -220,6 +221,7 @@ int main(void)
220221
IdMap_drop(&idnames);
221222
}
222223
```
224+
<!--{%endraw%}-->
223225

224226
### Example 4
225227
Demonstrate smap with plain-old-data key type Vec3i and int as mapped type: smap<Vec3i, int>.

0 commit comments

Comments
 (0)