This is for the design and behavior of Java style iterators. Iterators have two important states associated with them:
, .
next() previous() . next(), . previous() .
. - . v .
i.toFront();
-v
4000 4100 4200 4234
0 1 2 3
i.next();
----v
4000 4100 4200 4234
0 1 2 3
i.next();
----v
4000 4100 4200 4234
0 1 2 3
i.previous();
v----
4000 4100 4200 4234
0 1 2 3
i.previous();
v----
4000 4100 4200 4234
0 1 2 3
:
#include <QtCore>
int main()
{
QMap<double, int> map;
map.insert(4234., 3);
map.insert(4200., 2);
map.insert(4100., 1);
map.insert(4000., 0);
QMapIterator<double, int> i(map);
i.toFront();
i.next();
qDebug() << i.key() << i.value();
i.next();
qDebug() << i.key() << i.value();
i.previous();
qDebug() << i.key() << i.value();
i.previous();
qDebug() << i.key() << i.value();
}
:
4000 0
4100 1
4100 1
4000 0
, , ++ .