vendredi 18 septembre 2015

C++ STL std::random_shuffle cannot pass custom random number generator

I want to random_shuffle a vector (I know that random_shuffle is depreciated), but I get a compile error when I pass my custom random function which I copied from another thread on here. Can someone show me how to call random_shuffle using the random number generator posted below?

random_shuffle(defects.begin(), defects.end(), xorshf96);

unsigned int xorshf96(void) {          //period 2^96-1
    unsigned int t;
    x ^= x << 16;
    x ^= x >> 5;
    x ^= x << 1;

    t = x;
    x = y;
    y = z;
    z = t ^ x ^ y;

    return z;
}




Aucun commentaire:

Enregistrer un commentaire