diff options
| author | Tyge Løvset <[email protected]> | 2022-12-23 23:55:10 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-12-23 23:55:10 +0100 |
| commit | d623c6c85071b9af5d607bb5d9aceceaea05220a (patch) | |
| tree | f20fc3714f86e1553d1103bed6dc8efefcbd9d6b /misc/examples/birthday.c | |
| parent | 5f57d597cd27aef55adbcb3b452973b0c6e33667 (diff) | |
| download | STC-modified-d623c6c85071b9af5d607bb5d9aceceaea05220a.tar.gz STC-modified-d623c6c85071b9af5d607bb5d9aceceaea05220a.zip | |
Experimental uppercase macros.
Diffstat (limited to 'misc/examples/birthday.c')
| -rw-r--r-- | misc/examples/birthday.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/misc/examples/birthday.c b/misc/examples/birthday.c index 48b8ceaa..be7f0457 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 /= 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 - (double)i.ref->second / sum)); |
