Iterators v.s. index based for loops
Quote:
For that reason, iterators are rarely useful in connection with QList. One place where STL-style iterators do make sense is as arguments to generic
doc.trolltech.com/4.2/qlist-iterator.html
So if I have a for loop, where the macro foreach isn't an option. Should I use iterators or indexes?
Code:
for(int i = 0; i < list.size(); i++) {
Do something with list[i]
blah blah blah
}
Code:
for(QList<type>::iterator i = list.begin(); i != list.end(); ++i) {
Do something with *i
blah blah blah
}
Re: Iterators v.s. index based for loops
Re: Iterators v.s. index based for loops
Thanks so much. The kind of answer I was looking for.