El método reset() de la clase uniform_real_distribution en C++ se usa para restablecer esta uniform_real_distribution.
Sintaxis:
void reset();
Parámetros: Este método no acepta ningún parámetro.
Valor devuelto: este método no devuelve nada.
Ejemplo:
// C++ code to demonstrate // the working of reset() function #include <iostream> // for uniform_real_distribution function #include <random> using namespace std; int main() { double a = 10, b = 20.5; default_random_engine generator; // Initializing of uniform_real_distribution class uniform_real_distribution<double> distribution(a, b); cout << "Next value in uniform_int_distribution: " << distribution(generator) << endl; cout << "Next value in uniform_int_distribution: " << distribution(generator) << endl; cout << "Next value in uniform_int_distribution: " << distribution(generator) << endl; // Using reset() distribution.reset(); cout << endl << "uniform_int_distribution has been reset." << endl << endl; // Now the next value won't be in the previous progression // and will be another progression cout << "Now next value in uniform_int_distribution: " << distribution(generator) << endl; return 0; }
Producción:
Next value in uniform_int_distribution: 11.3811 Next value in uniform_int_distribution: 14.8158 Next value in uniform_int_distribution: 12.2991 uniform_int_distribution has been reset. Now next value in uniform_int_distribution: 17.1281
Referencia: http://www.cplusplus.com/reference/random/uniform_real_distribution/reset/