-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgenLists.cpp
More file actions
36 lines (29 loc) · 760 Bytes
/
Copy pathgenLists.cpp
File metadata and controls
36 lines (29 loc) · 760 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 <cstdio>
#include <algorithm>
#include <random>
#include "constants.h"
int main(/*int argc, char **argv*/){
uint32_t *numbers = new uint32_t[poolSize];
// create simple list
for(size_t i=0; i<poolSize; ++i){
numbers[i] = i;
}
uint32_t *list = new uint32_t[arraySize];
std::random_device rng;
FILE *fd = fopen("test.dat", "wb");
for(size_t i=0; i<listCount; ++i){
// random shuffle
std::shuffle(numbers, numbers+poolSize, rng);
// copy smaller list from big random list
std::copy(numbers, numbers+arraySize, list);
// sort list
std::sort(list, list+arraySize);
// write to file
fwrite(list, 4, arraySize, fd);
printf("done %3lu/%lu\n", i+1, listCount);
}
fclose(fd);
delete[] numbers;
delete[] list;
return 0;
}