[docs] Fix reverse STL iteration example
Use reverse_iterator, now that we finally have it. Change-Id: If74ead1a6075c5437c1d111206913481a495a014 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
143c684364
commit
f4502fbaf0
@ -156,10 +156,9 @@ for (i = list.begin(); i != list.end(); ++i)
|
|||||||
QList<QString> list;
|
QList<QString> list;
|
||||||
list << "A" << "B" << "C" << "D";
|
list << "A" << "B" << "C" << "D";
|
||||||
|
|
||||||
QList<QString>::iterator i = list.end();
|
QList<QString>::reverse_iterator i;
|
||||||
while (i != list.begin()) {
|
for (i = list.rbegin(); i != list.rend(); ++i)
|
||||||
--i;
|
*i = i->toLower();
|
||||||
*i = (*i).toLower();
|
|
||||||
}
|
}
|
||||||
//! [11]
|
//! [11]
|
||||||
|
|
||||||
|
@ -472,9 +472,7 @@
|
|||||||
|
|
||||||
\image stliterators1.png
|
\image stliterators1.png
|
||||||
|
|
||||||
Iterating backward with an STL-style iterator requires us to
|
Iterating backward with an STL-style iterator is done with reverse iterators:
|
||||||
decrement the iterator \e before we access the item. This
|
|
||||||
requires a \c while loop:
|
|
||||||
|
|
||||||
\snippet code/doc_src_containers.cpp 11
|
\snippet code/doc_src_containers.cpp 11
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user