aboutsummaryrefslogtreecommitdiff
path: root/src/random.cc
blob: dba3647cfba23064c0174d97782e86c48825c63f (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
#include "random.h"

namespace utility {

std::size_t Random::Range::get() {
	return this->distribution_(*(this->generator_));
}

Random::Range::Range(
	std::mt19937* const generator,
	const std::size_t   a,
	const std::size_t   b
):
	generator_(generator),
	distribution_(a, b) { }

Random::Random():
	device_{},
	generator_{device_()} { }

Random::Range Random::makeRange(
	const std::size_t a,
	const std::size_t b) {
	this->generator_.seed(this->device_());

	return Range{&(this->generator_), a, b};
}

}