In order to give functions the option to modify the vector I can\'t do
curr = myvec.at( i );
doThis( curr );
doThat( curr );
doStuffWith( curr );
The complexity of at()
is constant, i.e., in practice this means that it must be designed to not have any relevant performance penalty.
You can use []
, which is also constant complexity, but does not check bounds. This would be equivalent to using pointer arithmetic and, thus, potentially a bit faster than the former.
In any case, vector is specifically designed for constant performance access to any of its elements. So this should be the least of your worries.