-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom.h
51 lines (42 loc) · 937 Bytes
/
random.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
/**
* @file random.h
* Random library declarations.
* Originally written for use with the Graph class to generate random
* graphs and integers.
*
* @author Sean Massung
* @date Spring 2011
*/
#pragma once
#include <vector>
using std::vector;
/**
* Provides random functionality per a given seed.
* This is useful when you want predictably random things, like for grading.
*/
class Random
{
public:
/**
* Constructor.
* @param seed - seed to initialize the RNG
*/
inline Random(unsigned long seed);
/**
* @return a random integer
*/
inline int nextInt();
/**
* Randomly shuffles a vector with the current seed state.
* @param array - the vector to shuffle
*/
template <class T>
void shuffle(vector<T>& array);
private:
unsigned long shiftRegister;
/**
* @return a random bit
*/
inline bool LFSR();
};
#include "random.cpp"