From 5daba7ad2291dd7f02299eabeb650d0d0b77a1a6 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 4 Oct 2022 16:38:41 +0200 Subject: - Removed deprecated c_forrange() (replaced by c_forloop + crange type) - Removed csview_new(literal) macro. Use c_sv(literal) instead. - Added stc/views.h: moved crange from ccommon.h and added templated type c_listview. Instantiate by: using_listview(ViewName, ValueType) after #include, does not use #define i_val .... See examples in views.h. --- docs/ccommon_api.md | 11 +++++------ docs/csview_api.md | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'docs') diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md index 912601e7..1cdc56cb 100644 --- a/docs/ccommon_api.md +++ b/docs/ccommon_api.md @@ -263,17 +263,16 @@ Note that `c_flt_take()` is given as an optional argument, which makes the loop ### crange **crange** is a number sequence generator type. The **crange_value** type is `long long`. Below, *start*, *stop*, *step* are type *crange_value*: ```c -crange crange_init(void); // will generate 0, 1, 2, ... -crange crange_make(stop); // will generate 0, 1, ..., stop-1 -crange crange_make(start, stop); // will generate start, start+1, ... stop-1 -crange crange_make(start, stop, step); // will generate start, start+step, ... upto-not-including stop +crange crange_init(stop); // will generate 0, 1, ..., stop-1 +crange crange_init(start, stop); // will generate start, start+1, ... stop-1 +crange crange_init(start, stop, step); // will generate start, start+step, ... upto-not-including stop // note that step may be negative. crange_iter crange_begin(crange* self); crange_iter crange_end(crange* self); void crange_next(crange_iter* it); // 1. All primes less than 32: -crange r1 = crange_make(3, 32, 2); +crange r1 = crange_init(3, 32, 2); printf("2"); // first prime c_forfilter (i, crange, r1 , isPrime(*i.ref)) @@ -281,7 +280,7 @@ c_forfilter (i, crange, r1 // 2 3 5 7 11 13 17 19 23 29 31 // 2. The 11 first primes: -crange r2 = crange_make(3, INTMAX_MAX, 2); +crange r2 = crange_init(3, crange_MAX, 2); printf("2"); c_forfilter (i, crange, r2 , isPrime(*i.ref) diff --git a/docs/csview_api.md b/docs/csview_api.md index 70587911..25bb8c84 100644 --- a/docs/csview_api.md +++ b/docs/csview_api.md @@ -26,9 +26,8 @@ All csview definitions and prototypes are available by including a single header ## Methods ```c -csview c_sv(const char literal_only[]); // alias for csview_new +csview c_sv(const char literal_only[]); // construct from literal, no strlen() csview c_sv(const char* str, size_t n); // overloaded csview constructor. -csview csview_new(const char literal_only[]); // construct from literal, no strlen() csview csview_from(const char* str); // construct from const char* void csview_clear(csview* self); -- cgit v1.2.3