该类提供一个java风格的非常量的迭代器为QVector和QStack。
#include <QMutableVectorIterator>
QMutableVectorIterator ( QVector<T> & vector ) |
|
~QMutableVectorIterator
()
|
|
bool
|
findNext
( const T & value )
|
bool
|
findPrevious
( const T & value )
|
bool
|
hasNext
() const
|
bool
|
hasPrevious
() const
|
void
|
insert
( const T & value )
|
T &
|
next
()
|
T &
|
peekNext
() const
|
T &
|
peekPrevious
() const
|
T &
|
previous
()
|
void
|
remove
()
|
void
|
setValue
( const T & value ) const
|
void
|
toBack
()
|
void
|
toFront
()
|
const T &
|
value
() const
|
T &
|
value
()
|
QMutableVectorIterator &
|
operator=
( QVector<T> & vector )
|
QVector<float> vector;
...
QVectorIterator<float> i(vector);
while (i.hasNext())
qDebug() << i.next();
QVectorIterator<float> i(vector);
i.toBack();
while (i.hasPrevious())
qDebug() << i.previous();
QMutableVectorIterator<int> i(vector);
while (i.hasNext()) {
int val = i.next();
if (val < 0) {
i.setValue(-val);
} else if (val == 0) {
i.remove();
}
}
QMutableVectorIterator<int> i(vector);
while (i.hasNext()) {
int val = i.next();
if (val < -32768 || val > 32767)
i.remove();
}
QMutableVectorIterator<double> i(list);
while (i.hasNext()) {
double val = i.next();
i.setValue(sqrt(val));
}