aboutsummaryrefslogtreecommitdiffstats
path: root/util/random/mersenne32.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/random/mersenne32.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/random/mersenne32.h')
-rw-r--r--util/random/mersenne32.h78
1 files changed, 39 insertions, 39 deletions
diff --git a/util/random/mersenne32.h b/util/random/mersenne32.h
index 861f3a3d38..f0cc84832b 100644
--- a/util/random/mersenne32.h
+++ b/util/random/mersenne32.h
@@ -1,50 +1,50 @@
#pragma once
-
+
#include <util/system/defaults.h>
-
+
class IInputStream;
-
-namespace NPrivate {
- class TMersenne32 {
+
+namespace NPrivate {
+ class TMersenne32 {
static constexpr int N = 624;
-
- public:
+
+ public:
inline TMersenne32(ui32 s = 19650218UL) noexcept
- : mti(N + 1)
- {
- InitGenRand(s);
- }
-
+ : mti(N + 1)
+ {
+ InitGenRand(s);
+ }
+
inline TMersenne32(const ui32* init_key, size_t key_length) noexcept
- : mti(N + 1)
- {
- InitByArray(init_key, key_length);
- }
-
+ : mti(N + 1)
+ {
+ InitByArray(init_key, key_length);
+ }
+
TMersenne32(IInputStream& input);
-
+
inline ui32 GenRand() noexcept {
- if (mti >= N) {
- InitNext();
- }
-
- ui32 y = mt[mti++];
-
- y ^= (y >> 11);
- y ^= (y << 7) & 0x9d2c5680UL;
- y ^= (y << 15) & 0xefc60000UL;
- y ^= (y >> 18);
-
- return y;
- }
-
- private:
+ if (mti >= N) {
+ InitNext();
+ }
+
+ ui32 y = mt[mti++];
+
+ y ^= (y >> 11);
+ y ^= (y << 7) & 0x9d2c5680UL;
+ y ^= (y << 15) & 0xefc60000UL;
+ y ^= (y >> 18);
+
+ return y;
+ }
+
+ private:
void InitNext() noexcept;
void InitGenRand(ui32 s) noexcept;
void InitByArray(const ui32* init_key, size_t key_length) noexcept;
-
- private:
- ui32 mt[N];
- int mti;
- };
-}
+
+ private:
+ ui32 mt[N];
+ int mti;
+ };
+}