Maze Builder Docs 8.8.13
Loading...
Searching...
No Matches
randomizer.h
Go to the documentation of this file.
1#ifndef RANDOMIZER_H
2#define RANDOMIZER_H
3
4#include <string_view>
5#include <vector>
6#include <memory>
7
10namespace mazes
11{
16 {
17 public:
20
23
26 randomizer(const randomizer& other);
27
32
35 randomizer(randomizer&& other) noexcept;
36
40 randomizer& operator=(randomizer&& other) noexcept;
41
46 int get_int(int low = 0, int high = 1) const noexcept;
47
53 [[nodiscard]] std::vector<int> sample_int_n(int low = 0, int high = 1, int n = 1) const;
54
60 [[nodiscard]] std::vector<float> sample_float_n(float low = 0.0f, float high = 1.0f, int n = 1) const;
61
66 [[nodiscard]] float get_float(float low = 0.0f, float high = 1.0f) const noexcept;
67
70 void seed(unsigned long long seed = 0) const noexcept;
71
74 void seed(std::string_view sv) const noexcept;
75
80 int operator()(const int low, const int high) const noexcept
81 {
82 return get_int(low, high);
83 }
84
85 private:
86 class randomizer_impl;
87
88 std::unique_ptr<randomizer_impl> m_impl;
89 };
90}
91#endif // RANDOMIZER_H
void seed(unsigned long long seed=0) const noexcept
Seeds the random number generator with the given seed value.
~randomizer()
Destructor.
int get_int(int low=0, int high=1) const noexcept
Generates a random integer within a specified range.
randomizer(randomizer &&other) noexcept
Move constructor.
std::vector< float > sample_float_n(float low=0.0f, float high=1.0f, int n=1) const
Samples n floats from a uniform distribution over [low, high).
randomizer & operator=(randomizer &&other) noexcept
Move assignment operator.
randomizer()
Default constructor.
std::vector< int > sample_int_n(int low=0, int high=1, int n=1) const
Samples n integers (with replacement) from a uniform distribution over [low, high].
randomizer & operator=(const randomizer &other)
Copy assignment operator.
float get_float(float low=0.0f, float high=1.0f) const noexcept
Generates a random float within a specified range.
randomizer(const randomizer &other)
Copy constructor.