C++: Optimizing speed with vector/array?

前端 未结 8 1799
半阙折子戏
半阙折子戏 2021-01-02 00:51

I have a nested for-loop structure and right now I am re-declaring the vector at the start of each iteration:

void function (n1,n2,bound,etc){

    for (int          


        
8条回答
  •  忘掉有多难
    2021-01-02 01:18

    The overhead of using a vector vs an array is minor, especially when you are getting a lot of useful functionality from the vector. Internally a vector allocates an array. So vector is the way to go.

提交回复
热议问题