1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Update Random.cpp

This commit is contained in:
Sandu Liviu Catalin 2020-05-19 17:18:05 +03:00
parent 1c814d8965
commit 98fda61a77

View File

@ -306,45 +306,39 @@ Float64 GetRandomFloat64(Float64 m, Float64 n)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void GetRandomString(String & str, String::size_type len) void GetRandomString(String & str, String::size_type len)
{ {
// Reserve the requested size + the null terminator
str.reserve(len+1);
// Resize to the requested size and fill with 0 // Resize to the requested size and fill with 0
str.resize(len); str.resize(len);
// Generate the requested amount of characters // Generate the requested amount of characters
for (auto & c : str) for (auto & c : str)
{
c = String_Dist(*RG32_MT19937); c = String_Dist(*RG32_MT19937);
// Append the null terminator }
str.push_back(0);
} }
void GetRandomString(String & str, String::size_type len, String::value_type n) void GetRandomString(String & str, String::size_type len, String::value_type n)
{ {
// Reserve the requested size + the null terminator
str.reserve(len+1);
// Resize to the requested size and fill with 0 // Resize to the requested size and fill with 0
str.resize(len); str.resize(len);
// Create the custom distribution // Create the custom distribution
std::uniform_int_distribution< String::value_type > dist(1, n); std::uniform_int_distribution< String::value_type > dist(1, n);
// Generate the requested amount of characters // Generate the requested amount of characters
for (auto & c : str) for (auto & c : str)
{
c = dist(*RG32_MT19937); c = dist(*RG32_MT19937);
// Append the null terminator }
str.push_back(0);
} }
void GetRandomString(String & str, String::size_type len, String::value_type m, String::value_type n) void GetRandomString(String & str, String::size_type len, String::value_type m, String::value_type n)
{ {
// Reserve the requested size + the null terminator
str.reserve(len+1);
// Resize to the requested size and fill with 0 // Resize to the requested size and fill with 0
str.resize(len); str.resize(len);
// Create the custom distribution // Create the custom distribution
std::uniform_int_distribution< String::value_type > dist(m, n); std::uniform_int_distribution< String::value_type > dist(m, n);
// Generate the requested amount of characters // Generate the requested amount of characters
for (auto & c : str) for (auto & c : str)
{
c = dist(*RG32_MT19937); c = dist(*RG32_MT19937);
// Append the null terminator }
str.push_back(0);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------