mn_ramdom_xorshift.hpp
Go to the documentation of this file.
1 
21 #ifndef __MINILIB_BASIC_RAMDOM_XORSHIFT_H__
22 #define __MINILIB_BASIC_RAMDOM_XORSHIFT_H__
23 
24 #include "../mn_config.hpp"
25 
26 #include "mn_random.hpp"
27 
28 namespace mn {
36  class basic_ramdom_xorshift : public IPseudoRandomUtil<unsigned int> {
38  public:
39  basic_ramdom_xorshift(unsigned int startSeed)
40  : base_type(startSeed) { init(startSeed); }
41 
47  virtual unsigned char rand8() override;
53  virtual unsigned short rand16() override;
59  virtual unsigned int rand32() override;
60 
61  virtual seed_t get_seed() override { return m_xorandArray[0]; }
62  virtual void set_seed(seed_t seed) override { init(seed); }
63  private:
64  void init(unsigned int seed);
65  private:
66  unsigned long m_xorandArray[4];
67  };
68 }
69 #endif // __MINILIB_BASIC_RAMDOM_XORSHIFT_H__
An Intarface for all randoms classes in this library.
Definition: mn_random.hpp:32
unsigned int seed_t
Definition: mn_random.hpp:44
Pseudro-Random Number Generator based on xor_shift128++ generator.
Definition: mn_ramdom_xorshift.hpp:36
void init(unsigned int seed)
Definition: mn_ramdom_xorshift.cpp:26
virtual unsigned char rand8() override
Get a random unsigned char number.
Definition: mn_ramdom_xorshift.cpp:39
virtual seed_t get_seed() override
Get the current used Seed.
Definition: mn_ramdom_xorshift.hpp:61
virtual unsigned short rand16() override
Get a random unsigned short number.
Definition: mn_ramdom_xorshift.cpp:46
virtual void set_seed(seed_t seed) override
Set the a new seed.
Definition: mn_ramdom_xorshift.hpp:62
unsigned long m_xorandArray[4]
Definition: mn_ramdom_xorshift.hpp:66
basic_ramdom_xorshift(unsigned int startSeed)
Definition: mn_ramdom_xorshift.hpp:39
virtual unsigned int rand32() override
Get a random unsigned int number.
Definition: mn_ramdom_xorshift.cpp:53
Definition: mn_allocator_typetraits.hpp:25