There is a vector of vectors:
std::vector <std::vector <float> > VoV;
VoV.resize(num); // num is determined at run-time
for (int i=0; i<num; ++i) {
VoV[i].resize(3); // initializing to zero
}
I want to set all three elements to zero after some manipulation. I mean, I know initially they will be set to zero however, their values will change after a while and I want to set them all zero again. So, is the following correct? Is it efficient and is there a better way?
std::fill(VoV.begin(), VoV.end(), 0.f);
There are many ways you can set all of the data to zero. The simplest is perhaps:
Or,
Or,
Or even:
Note: I haven’t tested any of these.