Hello ,
I have a vector which stores positions .
CRectangle *_final_positions;// CRectangle is a simple rectangle(x,y,w,h)
vector<CRectangle*>_final_positions_List;
// It has some values inserted in it .
for(int i = 0;i < 3;i++)
{
for(int j = 0;j < 3;j++)
{
_final_positions = NULL;
_final_positions = new CRectangle((float)j * 75,(float)i * 100,(float)75,(float)100);
_final_positions_List.push_back(_final_positions);
}
}
//Finally , I want to swap these positions so I have written a function
swap_positions()
{
for(int i = 0;i < _final_positions_List.size();i++)
{
int temp = GetRandomInteger(0,9);
swap(_final_positions_List[i],_final_positions_List[temp]);
}
}
Note :
where GetRandomInteger(min,max) generates a random integer starting from min to max.
** My problem is by doing this , I have some duplicate positions. How to solve this?