summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/birthday.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-02-08 16:16:49 +0100
committerTyge Løvset <[email protected]>2023-02-08 17:18:24 +0100
commitc4441f5fc665194fbd7a894a67a64a08c3beac42 (patch)
tree82f231b6e8fcb75625166f98aa785baaa265a3d6 /misc/examples/birthday.c
parent673dd5319a488d4b702b94dd9aeda4e497ae4fbc (diff)
downloadSTC-modified-c4441f5fc665194fbd7a894a67a64a08c3beac42.tar.gz
STC-modified-c4441f5fc665194fbd7a894a67a64a08c3beac42.zip
Changed to use lowercase flow-control macros in examples (uppercase will still be supported). Improved many examples to use c_make() to init containers.
Diffstat (limited to 'misc/examples/birthday.c')
-rw-r--r--misc/examples/birthday.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/misc/examples/birthday.c b/misc/examples/birthday.c
index 63f64016..cb627ef8 100644
--- a/misc/examples/birthday.c
+++ b/misc/examples/birthday.c
@@ -18,10 +18,10 @@ static void test_repeats(void)
printf("birthday paradox: value range: 2^%d, testing repeats of 2^%d values\n", BITS, BITS_TEST);
stc64_t rng = stc64_new(seed);
- c_AUTO (cmap_ic, m)
+ c_auto (cmap_ic, m)
{
cmap_ic_reserve(&m, N);
- c_FORRANGE (i, N) {
+ c_forrange (i, N) {
uint64_t k = stc64_rand(&rng) & mask;
int v = cmap_ic_insert(&m, k, 0).ref->second += 1;
if (v > 1) printf("repeated value %" PRIu64 " (%d) at 2^%d\n",
@@ -42,17 +42,17 @@ void test_distribution(void)
stc64_t rng = stc64_new(seed);
const size_t N = 1ull << BITS ;
- c_AUTO (cmap_x, map) {
- c_FORRANGE (N) {
+ c_auto (cmap_x, map) {
+ c_forrange (N) {
uint64_t k = stc64_rand(&rng);
cmap_x_insert(&map, k & 0xf, 0).ref->second += 1;
}
uint64_t sum = 0;
- c_FOREACH (i, cmap_x, map) sum += i.ref->second;
+ c_foreach (i, cmap_x, map) sum += i.ref->second;
sum /= (uint64_t)map.size;
- c_FOREACH (i, cmap_x, map) {
+ c_foreach (i, cmap_x, map) {
printf("%4" PRIu32 ": %" PRIu64 " - %" PRIu64 ": %11.8f\n",
i.ref->first, i.ref->second, sum,
(1.0 - (double)i.ref->second / (double)sum));