forked from ifsmirnov/jngen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rnds.h
56 lines (42 loc) · 1.3 KB
/
rnds.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include "array.h"
#include "common.h"
#include "random.h"
#include "sequence_ops.h"
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
namespace jngen {
typedef std::pair<long long, long long> HashBase; // (mod, base)
typedef std::pair<std::string, std::string> StringPair;
class StringRandom {
public:
StringRandom() {
static bool created = false;
ENSURE(!created, "jngen::StringRandom should be created only once");
created = true;
}
static std::string random(int len, const std::string& alphabet = "a-z");
template<typename ... Args>
static std::string random(const std::string& pattern, Args... args) {
return rnd.next(pattern, std::forward(args)...);
}
static std::string thueMorse(int len, char first = 'a', char second = 'b');
static std::string abacaba(int len, char first = 'a');
static StringPair antiHash(
const std::vector<HashBase>& bases,
const std::string& alphabet = "a-z",
int length = -1);
};
JNGEN_EXTERN StringRandom rnds;
} // namespace jngen
using jngen::rnds;
#ifndef JNGEN_DECLARE_ONLY
#define JNGEN_INCLUDE_RNDS_INL_H
#include "impl/rnds_inl.h"
#undef JNGEN_INCLUDE_RNDS_INL_H
#endif // JNGEN_DECLARE_ONLY