diff options
| author | Tyge Løvset <[email protected]> | 2023-06-11 14:03:16 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-06-11 14:59:06 +0200 |
| commit | b564ef6bdfcd2437f1b4997f42054c45ccdedbb1 (patch) | |
| tree | b6c5458b8bc47279d18408f25e79eb6118808d78 /include/stc/algo | |
| parent | f3529a2600141dc7f84c734ea3bf5db8f7090e56 (diff) | |
| download | STC-modified-b564ef6bdfcd2437f1b4997f42054c45ccdedbb1.tar.gz STC-modified-b564ef6bdfcd2437f1b4997f42054c45ccdedbb1.zip | |
Added priv/linkage.h and renamed priv/template2.h => priv/template_undef.h.
Make all examples c++ compatible, except those using cspan.h
Removed: crange_obj()
Renamed: crange_make() => crange_init()
Renamed: cspan_make() => cspan_init()
Renamed: cstr_NULL => cstr_null
Renamed: csview_NULL => csview_null
Diffstat (limited to 'include/stc/algo')
| -rw-r--r-- | include/stc/algo/coroutine.h | 2 | ||||
| -rw-r--r-- | include/stc/algo/crange.h | 18 | ||||
| -rw-r--r-- | include/stc/algo/filter.h | 2 | ||||
| -rw-r--r-- | include/stc/algo/sort.h | 1 |
4 files changed, 11 insertions, 12 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h index 67ea5a40..5cd6d68f 100644 --- a/include/stc/algo/coroutine.h +++ b/include/stc/algo/coroutine.h @@ -56,7 +56,7 @@ int main(void) { return 0; } */ -#include <stc/ccommon.h> +#include "../ccommon.h" enum { cco_state_final = -1, diff --git a/include/stc/algo/crange.h b/include/stc/algo/crange.h index 56c317da..34ed541b 100644 --- a/include/stc/algo/crange.h +++ b/include/stc/algo/crange.h @@ -27,14 +27,15 @@ int main() { - crange r1 = crange_make(80, 90); + crange r1 = crange_init(80, 90); c_foreach (i, crange, r1) printf(" %lld", *i.ref); puts(""); // use a temporary crange object. int a = 100, b = INT32_MAX; - c_forfilter (i, crange, crange_obj(a, b, 8), + crange r2 = crange_init(a, b, 8); + c_forfilter (i, crange, r2, c_flt_skip(i, 10) && c_flt_take(i, 3)) printf(" %lld", *i.ref); @@ -44,20 +45,17 @@ int main() #ifndef STC_CRANGE_H_INCLUDED #define STC_CRANGE_H_INCLUDED -#include <stc/ccommon.h> - -#define crange_obj(...) \ - (*(crange[]){crange_make(__VA_ARGS__)}) +#include "../ccommon.h" typedef long long crange_value; typedef struct { crange_value start, end, step, value; } crange; typedef struct { crange_value *ref, end, step; } crange_iter; -#define crange_make(...) c_MACRO_OVERLOAD(crange_make, __VA_ARGS__) -#define crange_make_1(stop) crange_make_3(0, stop, 1) -#define crange_make_2(start, stop) crange_make_3(start, stop, 1) +#define crange_init(...) c_MACRO_OVERLOAD(crange_init, __VA_ARGS__) +#define crange_init_1(stop) crange_init_3(0, stop, 1) +#define crange_init_2(start, stop) crange_init_3(start, stop, 1) -STC_INLINE crange crange_make_3(crange_value start, crange_value stop, crange_value step) +STC_INLINE crange crange_init_3(crange_value start, crange_value stop, crange_value step) { crange r = {start, stop - (step > 0), step}; return r; } STC_INLINE crange_iter crange_begin(crange* self) diff --git a/include/stc/algo/filter.h b/include/stc/algo/filter.h index 8dc1ad74..f5de1811 100644 --- a/include/stc/algo/filter.h +++ b/include/stc/algo/filter.h @@ -47,7 +47,7 @@ int main() #ifndef STC_FILTER_H_INCLUDED #define STC_FILTER_H_INCLUDED -#include <stc/ccommon.h> +#include "../ccommon.h" // c_forfilter: diff --git a/include/stc/algo/sort.h b/include/stc/algo/sort.h index bbd58427..2e73b0fb 100644 --- a/include/stc/algo/sort.h +++ b/include/stc/algo/sort.h @@ -42,6 +42,7 @@ int main() { } */ #include "../ccommon.h" + #ifndef i_type #define i_at(arr, idx) (&arr[idx]) #ifndef i_tag |
