If you use boost , you can use this class ( debug_mode set to false , if you want randomization to be predictable between execution, you should set it to true ):
#include <iostream>
How can you test it with this code:
#include "Randomizer.h" #include <iostream> using namespace std; int main (int argc, char* argv[]) { vector<int> v; v.push_back(1);v.push_back(2);v.push_back(3);v.push_back(4);v.push_back(5); v.push_back(6);v.push_back(7);v.push_back(8);v.push_back(9);v.push_back(10); Randomizer::get_instance().random_shuffle(v.begin(), v.end()); for(unsigned int i=0; i<v.size(); i++){ cout << v[i] << ", "; } return 0; }
madx Feb 10 '15 at 15:43 2015-02-10 15:43
source share