From ad9a74ebe39cd3371c5cf3a46b6c0286c0667914 Mon Sep 17 00:00:00 2001 From: Tyge Lovset Date: Wed, 1 Feb 2023 13:05:38 +0100 Subject: Fixed docs of c_make() macro. --- README.md | 2 +- docs/ccommon_api.md | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d9daa174..63308051 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ News: Version 4.1 RC (Feb 2023) ------------------------------------------------ Major changes: - Signed sizes and indices for all containers (no more mixing unsigned/signed bugs). -- A new exciting **cspan** single/multi-dimensional array view. +- A new exciting [**cspan**](docs/cspan_api.md) single/multi-dimensional array view. - Updates on cregex with several new unicode character classes. - Uppercase flow-control macros (ccommon.h). Lowercase macros are [still supported](include/stc/priv/altnames.h). - [See detailed changes for version 4](#version-4). diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md index 43f747ab..54b0312d 100644 --- a/docs/ccommon_api.md +++ b/docs/ccommon_api.md @@ -104,7 +104,7 @@ NOTE: One must always make sure to unwind temporary allocated resources before a - it prevents forgetting to call the destructor at the end. The **checkauto** utility will report any misusages. The following example shows how to correctly break/return -from a `c_AUTO` scope: +from a `c_AUTO` scope: ```c int flag = 0; for (int i = 0; i + +#define i_key int +#define i_val int +#include ... -cset_str myset = c_initialize(cset_str, {"This", "is", "the", "story"}); +cset_str myset = c_make(cset_str, {"This", "is", "the", "story"}); // note: const char* values given! +int x = 7, y = 8; +cmap_int mymap = c_make(cmap_int, { {1, 2}, {3, 4}, {5, 6}, {x, y} }); ``` ### crange -**crange** is a number sequence generator type. The **crange_value** type is `long long`. Below, *start*, *stop*, *step* are type *crange_value*: +**crange** is a number sequence generator type. The **crange_value** type is `long long`. Below *start*, *stop*, and *step* are of type *crange_value*: ```c crange crange_make(stop); // will generate 0, 1, ..., stop-1 crange crange_make(start, stop); // will generate start, start+1, ... stop-1 @@ -286,14 +291,14 @@ void crange_next(crange_iter* it); // 1. All primes less than 32: crange r1 = crange_make(3, 32, 2); printf("2"); // first prime -c_FORFILTER (i, crange, r1 +c_FORFILTER (i, crange, r1 , isPrime(*i.ref)) printf(" %lld", *i.ref); // 2 3 5 7 11 13 17 19 23 29 31 // 2. The 11 first primes: printf("2"); -c_FORFILTER (i, crange, crange_literal(3, INT64_MAX, 2) +c_FORFILTER (i, crange, crange_literal(3, INT64_MAX, 2) , isPrime(*i.ref) , c_flt_take(10)) printf(" %lld", *i.ref); -- cgit v1.2.3