El método reset() de la clase uniform_int_distribution en C++ se usa para restablecer esta uniform_int_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_int_distribution function #include <random> using namespace std; int main() { int a = 10, b = 100; default_random_engine generator; // Initializing of uniform_int_distribution class uniform_int_distribution<int> 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: 10 Next value in uniform_int_distribution: 21 Next value in uniform_int_distribution: 78 uniform_int_distribution has been reset. Now next value in uniform_int_distribution: 51
Referencia: https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution/reset