summaryrefslogtreecommitdiff
path: root/generators.c
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2014-06-28 18:41:46 -0500
committerBobby Bingham <koorogi@koorogi.info>2014-06-29 12:10:20 -0500
commit92b07de2d70460f1911597118f3fac2612ccdf4c (patch)
treef83c6968d6d1f49add0ac67e19962ce2a00c3484 /generators.c
parentc1dfffd07c9cad2e545a3b8a8208c50588494ced (diff)
Generate nicer numbers for debugging
Diffstat (limited to 'generators.c')
-rw-r--r--generators.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/generators.c b/generators.c
index 002b128..c4a70a0 100644
--- a/generators.c
+++ b/generators.c
@@ -8,6 +8,19 @@ static void generate_random(int *buffer, size_t size)
{
srandom(1);
for (size_t i = 0; i < size; i++) buffer[i] = random();
+
+ /* compress the values to nice small numbers to make debugging nicer */
+#if 0
+ int maxcompressed = -1;
+ for (size_t compressed = 0; compressed < size; compressed++) {
+ size_t minidx = -1;
+ for (size_t i = 0; i < size; i++) {
+ if (maxcompressed < buffer[i] && (minidx >= size || buffer[i] < buffer[minidx]))
+ minidx = i;
+ }
+ buffer[minidx] = ++maxcompressed;
+ }
+#endif
}
static void generate_sorted(int *buffer, size_t size)
@@ -17,7 +30,7 @@ static void generate_sorted(int *buffer, size_t size)
static void generate_reverse(int *buffer, size_t size)
{
- for (size_t i = 0; i < size; i++) buffer[i] = INT_MAX - i;
+ for (size_t i = 0; i < size; i++) buffer[i] = size - i - 1;
}
static void generate_constant(int *buffer, size_t size)