B
barbaros
Hello,
Is there any advantage in performing a reserve operation before
inserting a large number of zeroes in an empty vector ?
Let me be more specific. In the code below, does the second line bring
any increase in performance ?
vector<float> v;
v.reserve(1000);
v.insert(v.end(),1000,0.0);
Note: I am not interested in using directly the constructor, e.g.
vector<float> v(1000,0.0);
Thank you. Cristian Barbarosie
http://cmaf.ptmat.fc.ul.pt/~barbaros/
Is there any advantage in performing a reserve operation before
inserting a large number of zeroes in an empty vector ?
Let me be more specific. In the code below, does the second line bring
any increase in performance ?
vector<float> v;
v.reserve(1000);
v.insert(v.end(),1000,0.0);
Note: I am not interested in using directly the constructor, e.g.
vector<float> v(1000,0.0);
Thank you. Cristian Barbarosie
http://cmaf.ptmat.fc.ul.pt/~barbaros/