mickey

6th March 2007, 00:07

hi I'm trying to do this:

vector < vector <double> > temp;

temp.resize(_set->size());

vector < vector <double> >::iterator iit=temp.begin();

int i=0;

vector < vector <double> >::iterator itra = _set->begin();

srand ((unsigned)time(NULL));

while ( ! _set->empty() ) {

do {

i = rand() % (int) _set->size();

cout << " i " << i << endl;

if (i == 0 && _set->size() == 1) break;

} while (i >= (int) _set->size() || i == 0);

temp.insert (temp.begin(), itra+i, itra+i); //here it is filling nothing

int dist = (int) distance (_set->begin(), _set->begin()+i);

_set->erase(itra+dist);

++iit;

}

*_set = temp;

my aim is take my vec of vec and shuffle its elements (its vectors).

Before chose a vector of _set at random, put it at begin of temp and erase it from _set; I've been trying this way and it seems me more difficult...

the calcolus of 'i' is ok. but insert doesn't work.

Can anyone help me?

thanks

vector < vector <double> > temp;

temp.resize(_set->size());

vector < vector <double> >::iterator iit=temp.begin();

int i=0;

vector < vector <double> >::iterator itra = _set->begin();

srand ((unsigned)time(NULL));

while ( ! _set->empty() ) {

do {

i = rand() % (int) _set->size();

cout << " i " << i << endl;

if (i == 0 && _set->size() == 1) break;

} while (i >= (int) _set->size() || i == 0);

temp.insert (temp.begin(), itra+i, itra+i); //here it is filling nothing

int dist = (int) distance (_set->begin(), _set->begin()+i);

_set->erase(itra+dist);

++iit;

}

*_set = temp;

my aim is take my vec of vec and shuffle its elements (its vectors).

Before chose a vector of _set at random, put it at begin of temp and erase it from _set; I've been trying this way and it seems me more difficult...

the calcolus of 'i' is ok. but insert doesn't work.

Can anyone help me?

thanks