Speed accessing a std::vector by iterator vs by operator[]/index?

后端 未结 11 874
刺人心
刺人心 2020-12-03 04:42

Say, I have a

std::vector v;

in my code and I need to access its elements very often in the program, looping them forwa

11条回答
  •  情话喂你
    2020-12-03 04:50

    If speed matters, then you should have time and will to run a profiler on it and see which works best in your case.

    If it doesn't matter, then you are performing premature optimization and should STOP doing it.

提交回复
热议问题