vector reserve c++

前端 未结 4 470
春和景丽
春和景丽 2021-01-13 11:13

I have a very large multidimensional vector that changes in size all the time. Is there any point to use the vector.reserve() function when I only know a good approximation

4条回答
  •  星月不相逢
    2021-01-13 11:56

    Whenever you push a vector into another vector, set the size in the pushed vectors constructor:

     A.push_back(vector>( somesize ));
    

提交回复
热议问题