From bafafe81946b23e745fdcdc61a226984b26de42d Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Fri, 5 Apr 2024 22:02:01 -0400 Subject: [PATCH] fixup example --- examples/ex_4.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/ex_4.c b/examples/ex_4.c index 99b40fc..a9135f7 100644 --- a/examples/ex_4.c +++ b/examples/ex_4.c @@ -126,16 +126,16 @@ main(void) for (i = 2049; i < 2057; i++) { bool set = sparsemap_is_set(map, i); if (set) { - __diag("verified %d was set, %s\n", i); + __diag("verified %d was set\n", i); } else { - __diag("darn, %d was not really set, %s\n", i); + __diag("darn, %d was not really set\n", i); } } __diag("and %d was %s", i, sparsemap_is_set(map, i + 1) ? "set" : "not set"); rank = sparsemap_rank(map, 2048, 2060); __diag("rank was %lu at offset 109\n", rank); - rank = sparsemap_span(map, 2048, 8); - __diag("span was found at %lu\n", rank); + //rank = sparsemap_span(map, 2048, 8); + //__diag("span was found at %lu\n", rank); sparsemap_clear(map); // seed the PRNG @@ -146,7 +146,7 @@ main(void) #endif for (i = 0; i < TEST_ARRAY_SIZE; i++) { - array[i] = (int)__random(&prng) % 7000 + 1; + array[i] = (int)__random(&prng) % TEST_ARRAY_SIZE + 1; if (array[i] < 0) { i--; } @@ -161,15 +161,16 @@ main(void) assert(sparsemap_is_set(map, array[i]) == true); } - size_t l = sparsemap_span(map, 0, 8); - __diag("found span of 8 at %lu starting from 0\n", l); - for (i = (int)l; i < l + 8; i++) { - bool set = sparsemap_is_set(map, l + i); + size_t len = 6; + size_t l = sparsemap_span(map, 0, len); + __diag("found span of %d at %lu starting from 0\n", len, l); + for (i = (int)l; i < l + len; i++) { + bool set = sparsemap_is_set(map, i); if (set) { - __diag("verified %lu was set\n", l + i); + __diag("verified %lu was set\n", i); } else { - __diag("darn, %lu was not really set, %s\n", l + i, - was_set(l + i, array) ? "but we thought it was" : "because it wasn't"); + __diag("darn, %lu was not really set, %s\n", i, + was_set(i, array) ? "but we thought it was" : "because it wasn't"); } }