Hi,

Suppose I have the following code segment:

Code:
std::vector<float> X(5, 1.0);
std::vector<float>::iterator IterX;
for(IterX = X.begin(); IterX != X.end(); IterX++) {
std::cout << *Iter << " ";
}
and the following code segment:

Code:
std::vector<float> X(5, 1.0);
for(int i = 0; i < 5; i++) {
std::cout << X.at(i) << " ";
}
Which segment would be more efficient in terms of performance? I don't know how at() is implemented in the STL, but my guess would be that each time at() is called, the compiler internally creates an interator and iterates it the required number of times before dereferencing it. But I am not sure, because the book I am reading does say that std::vector<> provides fast random access to its elements.

Can anyone here please help me?

*****

Note: this is not homework! I am not in school.