-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_string.hpp
More file actions
35 lines (30 loc) · 1007 Bytes
/
random_string.hpp
File metadata and controls
35 lines (30 loc) · 1007 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
//
// Created by Patrick Moffitt on 12/16/17.
//
#ifndef COMPARE_MAPS_RANDOM_KEY_HPP
#define COMPARE_MAPS_RANDOM_KEY_HPP
#include <string>
#include <vector>
#include <random>
using namespace std;
/*
* Generates arbitrary length random (printable) strings and unique vectors of the same.
*/
struct Random_string {
static constexpr char printable_chars[] =
"!#$%&()[]^*+,_-./:;<=>?@|~"
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
static constexpr int printable_chars_size = sizeof(printable_chars) - 1;
string random_string(int length);
static random_device rd;
static mt19937 mt_engine;
static uniform_int_distribution<int> rand_char;
/*
* Beware: No range checking provided. Do not requested more unique strings than are possible
* for the given key_width.
*/
vector<string> random_strings(int key_width = 0, const int list_length = 0);
};
#endif //COMPARE_MAPS_RANDOM_KEY_HPP