C
carl
What is fastest, indexing or iterating a std::vector:
std::vector<std::string> container;
// Add 100000 strings to container
std::vector<std::string>::iterator it = container.begin()
while (it != container.end()) {
std::string str = *it;
// do something with str
it++;
}
or
int size = container.size();
for (int i=0; i< size; i++) {
std::string str = container;
// do something with str
}
On this page:
http://stackoverflow.com/questions/...-an-stl-vector-with-vectoriterator-or-with-at
there are some different opinions, but what are your experinces?
std::vector<std::string> container;
// Add 100000 strings to container
std::vector<std::string>::iterator it = container.begin()
while (it != container.end()) {
std::string str = *it;
// do something with str
it++;
}
or
int size = container.size();
for (int i=0; i< size; i++) {
std::string str = container;
// do something with str
}
On this page:
http://stackoverflow.com/questions/...-an-stl-vector-with-vectoriterator-or-with-at
there are some different opinions, but what are your experinces?