18 #define FOLLY_RANDOM_H_ 23 #include <type_traits> 29 #if FOLLY_HAVE_EXTRANDOM_SFMT19937 80 return Random::secureRandom<result_type>();
94 #if FOLLY_HAVE_EXTRANDOM_SFMT19937 103 static void secureRandom(
void*
data,
size_t len);
109 static typename std::enable_if<
114 secureRandom(&val,
sizeof(val));
122 return secureRandom<uint32_t>();
130 return rand32(max, srng);
138 return rand32(min, max, srng);
145 return secureRandom<uint64_t>();
153 return rand64(max, srng);
161 return rand64(min, max, srng);
169 return rand32(0, n, srng) == 0;
177 return randDouble01(srng);
185 return randDouble(min, max, srng);
196 template <
class RNG = DefaultGenerator,
class =
ValidRNG<RNG>>
207 template <
class RNG = DefaultGenerator,
class =
ValidRNG<RNG>>
238 return rand32(0, max, rng);
257 return std::uniform_int_distribution<uint32_t>(
min, max - 1)(rng);
287 return rand64(0, max, rng);
305 return std::uniform_int_distribution<uint64_t>(
min, max - 1)(rng);
323 return rand32(0, n, rng) == 0;
338 return std::generate_canonical<double, std::numeric_limits<double>::digits>(
354 if (std::fabs(max - min) < std::numeric_limits<double>::epsilon()) {
357 return std::uniform_real_distribution<double>(
min,
max)(rng);
static uint64_t rand64(uint64_t min, uint64_t max)
static uint64_t rand64(RNG &&rng)
static constexpr result_type min()
static std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value, T >::type secureRandom()
static double secureRandDouble01()
static uint32_t secureRand32()
static double secureRandDouble(double min, double max)
static double randDouble01(RNG &&rng)
static uint32_t rand32(uint32_t min, uint32_t max, RNG &&rng)
static uint64_t secureRand64(uint64_t max)
static constexpr result_type max()
typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value, T >::type result_type
static bool oneIn(uint32_t n)
—— Concurrent Priority Queue Implementation ——
typename std::enable_if< std::is_unsigned< invoke_result_t< RNG & >>::value, RNG >::type ValidRNG
static bool oneIn(uint32_t n, RNG &&rng)
static double randDouble(double min, double max, RNG &&rng)
static uint64_t rand64(uint64_t max)
static uint64_t secureRand64()
static uint32_t secureRand32(uint32_t max)
constexpr auto data(C &c) -> decltype(c.data())
static constexpr result_type max()
static const char *const value
static uint32_t rand32(RNG &&rng)
static uint32_t secureRand32(uint32_t min, uint32_t max)
static double randDouble01()
std::mt19937 DefaultGenerator
static double randDouble(double min, double max)
static constexpr result_type min()
static uint32_t rand32(uint32_t min, uint32_t max)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
static uint32_t rand32(uint32_t max, RNG &&rng)
static bool secureOneIn(uint32_t n)
static uint32_t rand32(uint32_t max)
static uint64_t secureRand64(uint64_t min, uint64_t max)
uint32_t randomNumberSeed()
static uint64_t rand64(uint64_t max, RNG &&rng)
static uint64_t rand64(uint64_t min, uint64_t max, RNG &&rng)