So I have a vector that I want to iterate through randomly, and by random I mean that each element is only accessed once but I don't want to shuffle the vector because the vector elements are large.
So I want this functionality:
1 2 3 4 5 6 7 8 9
std::vector<SomeLargeObjectWithoutACopyConstructor> myvec;
// ...fill myvec
std::random_shuffle(myvec.begin(),myvec.end());
for (auto& value : myvec)
{
// do stuff
}
Only I don't want to do this because the object type has no copy constructor and is large, so I don't want to shuffle the vector, just the iteration path. Is there a simple and efficient way of iterating randomly through a vector while ensuring that each object is only accessed once?