-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.c
More file actions
36 lines (26 loc) · 663 Bytes
/
test.c
File metadata and controls
36 lines (26 loc) · 663 Bytes
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
35
36
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include "bitmap.h"
int main(int argc, char *argv[])
{
if (argc < 2)
return 1;
uint64_t capacity = strtoul(argv[1], NULL, 10);
if (capacity == 0)
return 2;
Bitmap_t bm;
uint64_t rand_val;
srand(time(NULL));
Bitmap_init(&bm, capacity);
for (int i = 0; i < capacity; i++) {
rand_val = rand() % 100;
if (rand_val > 80)
Bitmap_set(&bm, i, 1);
}
for (int i = 0; i < capacity; i++)
printf("%d: %s\n", i, Bitmap_at(&bm, i) ? "set" : "not set");
Bitmap_free(&bm);
return 0;
}