diff options
| author | Tyge Løvset <[email protected]> | 2023-02-13 18:52:20 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-02-13 18:52:20 +0100 |
| commit | 98f126a304f296dea2517d9e81c7f8e7b3aa80f5 (patch) | |
| tree | 549330c3e0598fed528f50eb1c33b7fb7474ce72 | |
| parent | a3645620cf4b8855801d9ca0cf7385de5a70c5d9 (diff) | |
| download | STC-modified-98f126a304f296dea2517d9e81c7f8e7b3aa80f5.tar.gz STC-modified-98f126a304f296dea2517d9e81c7f8e7b3aa80f5.zip | |
Changed name of c_flt_inc() to c_flt_count().
| -rw-r--r-- | docs/ccommon_api.md | 11 | ||||
| -rw-r--r-- | include/stc/algo/filter.h | 8 |
2 files changed, 9 insertions, 10 deletions
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md index 4553ada0..20517630 100644 --- a/docs/ccommon_api.md +++ b/docs/ccommon_api.md @@ -229,12 +229,12 @@ Iterate containers with stop-criteria and chained range filtering. | Built-in filter | Description | |:----------------------------------|:-------------------------------------| -| `c_flt_skip(it, numItems)` | Skip numItems | -| `c_flt_take(it, numItems)` | Take numItems | +| `c_flt_skip(it, numItems)` | Skip numItems (inc count) | +| `c_flt_take(it, numItems)` | Take numItems (inc count) | | `c_flt_skipwhile(it, predicate)` | Skip items until predicate is false | | `c_flt_takewhile(it, predicate)` | Take items until predicate is false | -| `c_flt_last(it)` | Get count of last filter successes | -| `c_flt_inc(it)` | Increment and return on the stack | +| `c_flt_count(it)` | Increment current and return value | +| `c_flt_last(it)` | Get value of last count/skip/take | `it.index` holds the index of the source item. ```c @@ -254,8 +254,7 @@ int main() { c_forfilter (i, crange, R, isPrime(*i.ref) - && (c_flt_skip(i, INT32_MAX) || - c_flt_last(i) % 25 == 0) + && c_flt_count(i) % 25 == 0 , c_flt_take(i, 10)) // breaks loop on false. { printf(" %d", *i.ref); diff --git a/include/stc/algo/filter.h b/include/stc/algo/filter.h index 65c6982a..6f8e1654 100644 --- a/include/stc/algo/filter.h +++ b/include/stc/algo/filter.h @@ -50,15 +50,15 @@ int main() #include <stc/ccommon.h> #ifndef c_NFILTERS - #define c_NFILTERS 14 /* 22, 30, .. */ +#define c_NFILTERS 32 #endif -#define c_flt_take(i, n) (c_flt_inc(i) <= (n)) -#define c_flt_skip(i, n) (c_flt_inc(i) > (n)) +#define c_flt_take(i, n) (c_flt_count(i) <= (n)) +#define c_flt_skip(i, n) (c_flt_count(i) > (n)) #define c_flt_skipwhile(i, pred) ((i).s2[(i).s2top++] |= !(pred)) #define c_flt_takewhile(i, pred) !c_flt_skipwhile(i, pred) #define c_flt_last(i) (i).s1[(i).s1top-1] -#define c_flt_inc(i) ++(i).s1[(i).s1top++] +#define c_flt_count(i) ++(i).s1[(i).s1top++] #define c_forfilter(...) c_MACRO_OVERLOAD(c_forfilter, __VA_ARGS__) |
