fixup example

This commit is contained in:
Gregory Burd 2024-04-05 22:02:01 -04:00
parent 9ceaae6bc8
commit bafafe8194

View file

@ -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");
}
}