EasyLocalpp  3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
random.hh
Go to the documentation of this file.
1 #if !defined(_RANDOM_HH_)
2 #define _RANDOM_HH_
3 
4 #include <random>
5 #include <iostream>
6 
7 namespace EasyLocal {
8 
9  namespace Core {
10 
16  class Random
17  {
18  public:
19  static std::mt19937 g;
20  static std::random_device dev;
21 
26  static int Int(int a, int b)
27  {
28  std::uniform_int_distribution<> d(a, b);
29  return d(g);
30  }
31 
33  static int Int()
34  {
35  std::uniform_int_distribution<> d;
36  return d(g);
37  }
43  static double Double(double a = 0, double b = 1)
44  {
45  std::uniform_real_distribution<> d(a, b);
46  return d(g);
47  }
48 
50  static int Seed(int seed)
51  {
52  g.seed(seed);
53  return Random::seed = seed;
54  }
55 
56  static int seed;
57  };
58  }
59 }
60 
61 #endif // _RANDOM_HH_
static int Seed(int seed)
Definition: random.hh:50
static std::random_device dev
Definition: random.hh:20
static std::mt19937 g
Definition: random.hh:19
static int Int(int a, int b)
Definition: random.hh:26
static double Double(double a=0, double b=1)
Definition: random.hh:43
static int Int()
Definition: random.hh:33