Possible Duplicate:
C++ STL: Which method of iteration over a STL container is better?
Efficiency of vector index access vs iterator access
Assuming an std::vector<int>
named numbers
, which of the following is faster?
for (vector<int>::iterator i = numbers.begin(); i != numbers.end(); i++)
cout << *i;
or..
for (int i = 0; i < numbers.size(); i++)
cout << numbers.at(i);
Which one is faster? Is there any significant difference?