In a scenario, where I want to remove a random value from a vector many times, it sounds useful to me to reinitialize a distribution. So, I wanna do the following:
std::vector<int> v;
//init v with some values
//...
std::default_random_engine randomGenerator;
std::uniform_int_distribution<uint> Distribution(0,v.size());
for(int i = 0; i < max; i++)
{
int curIndex = Distribution(randomGenerator);
//remove v[curIndex]
//...
//reinitialize the distibution with new vector size
Distribution.reinit(0,v.size());
}
Is there a way to do it like this? Or is there a better way to do it?
Aucun commentaire:
Enregistrer un commentaire