diff options
| author | Tyge Løvset <[email protected]> | 2022-12-30 12:36:13 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-12-30 14:38:39 +0100 |
| commit | 4f0f45422fb58e9b134445ad6a4ea96d806214e8 (patch) | |
| tree | ea0bb95c1f82fa5ec71218ce1f6d7ce9bfcc4e29 /include/stc/algo/filter.h | |
| parent | 0761c13f316cc98ae7756f3527931aa86bed5016 (diff) | |
| download | STC-modified-4f0f45422fb58e9b134445ad6a4ea96d806214e8.tar.gz STC-modified-4f0f45422fb58e9b134445ad6a4ea96d806214e8.zip | |
More restructuring of files and cleanup. Moved carr2.h and carr3.h to misc/include/old/ as it is not among classic containers.
Removed stctest.h: Recommending https://github.com/bvdberg/ctest instead.
Diffstat (limited to 'include/stc/algo/filter.h')
| -rw-r--r-- | include/stc/algo/filter.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/include/stc/algo/filter.h b/include/stc/algo/filter.h index 486568f2..10aeb7e7 100644 --- a/include/stc/algo/filter.h +++ b/include/stc/algo/filter.h @@ -23,24 +23,26 @@ /* #include <stdio.h> #define i_val int -#define i_capacity 10 #include <stc/cstack.h> #include <stc/algo/filter.h> int main() { - cstack_int stk = cstack_INITIALIZER(int, {1, 2, 3, 4, 5, 6, 7, 8, 9}); - - c_foreach (i, cstack_int, stk) - printf(" %d", *i.ref); - puts(""); - - c_forfilter (i, cstack_int, stk - , c_flt_skipwhile(i, *i.ref < 3) - && (*i.ref & 1) == 0 // even only - , c_flt_take(i, 2)) // break after 2 - printf(" %d", *i.ref); - puts(""); + c_WITH (cstack_int stk = {0}, cstack_int_drop(&stk)) { + c_FORLIST (i, int, {1, 2, 3, 4, 5, 6, 7, 8, 9}) + cstack_int_push(&stk, i); + + c_FOREACH (i, cstack_int, stk) + printf(" %d", *i.ref); + puts(""); + + c_FORFILTER (i, cstack_int, stk + , c_flt_skipwhile(i, *i.ref < 3) + && (*i.ref & 1) == 0 // even only + , c_flt_take(i, 2)) // break after 2 + printf(" %d", *i.ref); + puts(""); + } } */ #ifndef STC_FILTER_H_INCLUDED |
