From a6accef42671a7baca6f3e78cb9d8041afbb5df8 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Wed, 6 Oct 2021 11:28:24 +0200 Subject: [PATCH] Renamed functions and made static --- src/random.cpp | 16 ++++++++-------- src/random.hpp | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/random.cpp b/src/random.cpp index 0d7f9f3..3ec16ad 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -2,22 +2,22 @@ sc::random sc::random::singleton {}; -bool sc::random::random_bool() { +bool sc::random::boolean() { std::uniform_int_distribution dist {0, 1}; - return dist(_reng) == 1; + return dist(instance()._reng) == 1; } -int sc::random::random_int(int from, int to) { +int sc::random::int_between(int from, int to) { std::uniform_int_distribution dist {from, to}; - return dist(_reng); + return dist(instance()._reng); } -double sc::random::random_double() { +double sc::random::double01() { std::uniform_real_distribution dist {}; - return dist(_reng); + return dist(instance()._reng); } -double sc::random::random_double(double from, double to) { +double sc::random::double_between(double from, double to) { std::uniform_real_distribution dist {from, to}; - return dist(_reng); + return dist(instance()._reng); } diff --git a/src/random.hpp b/src/random.hpp index a040802..15f4a69 100644 --- a/src/random.hpp +++ b/src/random.hpp @@ -20,10 +20,10 @@ namespace sc { std::default_random_engine& engine() { return _reng; } - bool random_bool(); - int random_int(int from, int to); - double random_double(); - double random_double(double from, double to); + static bool boolean(); + static int int_between(int from, int to); + static double double01(); + static double double_between(double from, double to); template static T choice(const std::vector& vec) {