summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-31 00:20:26 +0100
committerTyge Løvset <[email protected]>2022-12-31 00:20:26 +0100
commit9d48d93be9be4e5702979c82c9445cd8d4e90d04 (patch)
treec7ec7f8e540f6fa4363430c90d9aa0ecd6eb11a2 /include/stc
parent9d59845f622fbb9c225bbe32246a3128ad9ec0b1 (diff)
downloadSTC-modified-9d48d93be9be4e5702979c82c9445cd8d4e90d04.tar.gz
STC-modified-9d48d93be9be4e5702979c82c9445cd8d4e90d04.zip
Moved fmt.h to include/c11 folder. Not used by the lib or examples as lib is c99 only.
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/algo/crange.h6
-rw-r--r--include/stc/algo/csort.h8
-rw-r--r--include/stc/algo/cspan.h10
3 files changed, 12 insertions, 12 deletions
diff --git a/include/stc/algo/crange.h b/include/stc/algo/crange.h
index ccdd13ae..933d97b2 100644
--- a/include/stc/algo/crange.h
+++ b/include/stc/algo/crange.h
@@ -28,15 +28,15 @@
int main()
{
crange r1 = crange_make(80, 90);
- c_foreach (i, crange, r1)
+ 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_LITERAL(a, b, 8)
+ c_FORFILTER (i, crange, crange_LITERAL(a, b, 8)
, i.index > 10
- , c_flt_take(i, 3))
+ , c_FLT_TAKE(i, 3))
printf(" %lld", *i.ref);
puts("");
}
diff --git a/include/stc/algo/csort.h b/include/stc/algo/csort.h
index 9b115398..9c6a1e80 100644
--- a/include/stc/algo/csort.h
+++ b/include/stc/algo/csort.h
@@ -27,7 +27,7 @@
#define c_PASTE(a, b) c_CONCAT(a, b)
#endif
-/* Generic Quicksort in C
+/* Generic Quicksort in C, performs as fast as c++ std::sort().
template params:
#define i_val - value type [required]
#define i_less - less function. default: *x < *y
@@ -38,8 +38,8 @@ template params:
#include <time.h>
#include <stdlib.h>
#define i_val int
-#include <stc/crandom.h>
#include <stc/algo/csort.h>
+#include <stc/crandom.h>
#ifdef __cplusplus
#include <algorithm>
#endif
@@ -47,10 +47,10 @@ template params:
int testsort(csortval_int *a, size_t size, const char *desc) {
clock_t t = clock();
#ifdef __cplusplus
- puts("std::sort");
+ printf("std::sort: ");
std::sort(a, a + size);
#else
- puts("csort");
+ printf("csort: ");
csort_int(a, size);
#endif
t = clock() - t;
diff --git a/include/stc/algo/cspan.h b/include/stc/algo/cspan.h
index d6d6dd56..e348d860 100644
--- a/include/stc/algo/cspan.h
+++ b/include/stc/algo/cspan.h
@@ -28,17 +28,17 @@ using_cspan(IntSpan, int);
int main()
{
int array[] = {1, 2, 3, 4, 5};
- IntSpan iv = {array, c_arraylen(array)};
+ IntSpan span = {array, c_ARRAYLEN(array)};
- c_foreach (i, IntSpan, iv)
+ c_FOREACH (i, IntSpan, span)
printf(" %d", *i.ref);
puts("");
// use a temporary IntSpan object.
- c_forfilter (i, IntSpan, cspan_LITERAL(IntSpan, {10, 20, 30, 23, 22, 21})
- , c_flt_skipwhile(i, *i.ref < 25)
+ c_FORFILTER (i, IntSpan, cspan_LITERAL(IntSpan, {10, 20, 30, 23, 22, 21})
+ , c_FLT_SKIPWHILE(i, *i.ref < 25)
&& (*i.ref & 1) == 0 // even only
- , c_flt_take(i, 2)) // break after 2
+ , c_FLT_TAKE(i, 2)) // break after 2
printf(" %d", *i.ref);
puts("");
}