blob: 002b128b0db3ca9a9c166f2e4c747e2848d8b92c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
#include "generators.h"
static void generate_random(int *buffer, size_t size)
{
srandom(1);
for (size_t i = 0; i < size; i++) buffer[i] = random();
}
static void generate_sorted(int *buffer, size_t size)
{
for (size_t i = 0; i < size; i++) buffer[i] = i;
}
static void generate_reverse(int *buffer, size_t size)
{
for (size_t i = 0; i < size; i++) buffer[i] = INT_MAX - i;
}
static void generate_constant(int *buffer, size_t size)
{
for (size_t i = 0; i < size; i++) buffer[i] = 42;
}
const struct generator generators[] = {
{ .name = "random", .func = generate_random },
{ .name = "sorted", .func = generate_sorted },
{ .name = "reverse", .func = generate_reverse },
{ .name = "constant", .func = generate_constant },
{ 0 }
};
|