mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
@@ -16,13 +16,21 @@
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "util/Random.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <random>
|
||||
|
||||
namespace util {
|
||||
|
||||
void
|
||||
Random::setSeed(size_t seed)
|
||||
{
|
||||
generator_.seed(seed);
|
||||
}
|
||||
|
||||
std::mt19937_64 Random::generator_{std::chrono::system_clock::now().time_since_epoch().count()};
|
||||
|
||||
} // namespace util
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "util/Assert.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <random>
|
||||
|
||||
namespace util {
|
||||
@@ -50,6 +51,14 @@ public:
|
||||
return distribution(generator_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the seed for the random number generator
|
||||
*
|
||||
* @param seed Seed to set
|
||||
*/
|
||||
static void
|
||||
setSeed(size_t seed);
|
||||
|
||||
private:
|
||||
static std::mt19937_64 generator_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user