aboutsummaryrefslogtreecommitdiff
path: root/src/randomization
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-06 13:29:10 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:54 +0200
commit0854ebbc0720c1691f2de661c4ce3467b71746c6 (patch)
tree6bede8baea394711056db7109f395e71e880e03d /src/randomization
parenta285df324deb579d262ea7cf484de4d6b11b28e4 (diff)
refactor: replace unsigned int with uint32_t
Diffstat (limited to 'src/randomization')
-rw-r--r--src/randomization/generator.cpp7
-rw-r--r--src/randomization/generator.hpp5
-rw-r--r--src/randomization/seed_generator.cpp2
-rw-r--r--src/randomization/seed_generator.hpp2
4 files changed, 7 insertions, 9 deletions
diff --git a/src/randomization/generator.cpp b/src/randomization/generator.cpp
index b9bcb8a..56fbbf1 100644
--- a/src/randomization/generator.cpp
+++ b/src/randomization/generator.cpp
@@ -1,14 +1,13 @@
#include "generator.hpp"
-RandomNumberGenerator::RandomNumberGenerator(const unsigned int &seed)
+RandomNumberGenerator::RandomNumberGenerator(const uint32_t &seed)
{
this->_generator = std::make_unique<std::mt19937>(seed);
}
-unsigned int RandomNumberGenerator::in_range(const unsigned int &a,
- const unsigned int &b) const
+uint32_t RandomNumberGenerator::in_range(const uint32_t &a, const uint32_t &b) const
{
- auto random_distribution = std::uniform_int_distribution<unsigned int>(a, b);
+ auto random_distribution = std::uniform_int_distribution<uint32_t>(a, b);
return random_distribution(*this->_generator);
}
diff --git a/src/randomization/generator.hpp b/src/randomization/generator.hpp
index 3acfc98..35bd9eb 100644
--- a/src/randomization/generator.hpp
+++ b/src/randomization/generator.hpp
@@ -8,10 +8,9 @@
class RandomNumberGenerator : public IRandomNumberGenerator
{
public:
- explicit RandomNumberGenerator(const unsigned int &seed);
+ explicit RandomNumberGenerator(const uint32_t &seed);
- [[nodiscard]] unsigned int in_range(const unsigned int &a,
- const unsigned int &b) const override;
+ [[nodiscard]] uint32_t in_range(const uint32_t &a, const uint32_t &b) const override;
private:
std::unique_ptr<std::mt19937> _generator;
diff --git a/src/randomization/seed_generator.cpp b/src/randomization/seed_generator.cpp
index fdb2b12..5d51e18 100644
--- a/src/randomization/seed_generator.cpp
+++ b/src/randomization/seed_generator.cpp
@@ -5,7 +5,7 @@ SeedGenerator::SeedGenerator(const std::shared_ptr<std::random_device> &random_d
{
}
-unsigned int SeedGenerator::random_seed() const
+uint32_t SeedGenerator::random_seed() const
{
return (*_random_device)();
}
diff --git a/src/randomization/seed_generator.hpp b/src/randomization/seed_generator.hpp
index 238fdbe..1447a8c 100644
--- a/src/randomization/seed_generator.hpp
+++ b/src/randomization/seed_generator.hpp
@@ -10,7 +10,7 @@ class SeedGenerator : public ISeedGenerator
public:
explicit SeedGenerator(const std::shared_ptr<std::random_device> &random_device);
- [[nodiscard]] unsigned int random_seed() const override;
+ [[nodiscard]] uint32_t random_seed() const override;
private:
const std::shared_ptr<std::random_device> &_random_device;