
2 Mar
2009
2 Mar
'09
6:35 p.m.
Thorsten Ottosen:
I guess your case above should be implemented as
for # of rows v.clear(); v.resize( n );
v.reserve( n );
for each element read e v.push_back_unchecked(e) process( v.begin(), v.end() ) ...
But as the example above shows, we do not need a growing push_back() here.
Yes, this second example was supposed to show that we sometimes need to alter the capacity. If you want it to argue for push_back, change the file format so that the rows are terminated with a sentinel instead of prefixed with n. :-)