diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp index 948437bf68b..4586e0d008c 100644 --- a/src/widgets/graphicsview/qsimplex_p.cpp +++ b/src/widgets/graphicsview/qsimplex_p.cpp @@ -230,12 +230,8 @@ bool QSimplex::setConstraints(const QList &newConstraints) setValueAt(i, c->helper.first->index, 1.0); } - QHash::const_iterator iter; - for (iter = c->variables.constBegin(); - iter != c->variables.constEnd(); - ++iter) { + for (auto iter = c->variables.cbegin(); iter != c->variables.cend(); ++iter) setValueAt(i, iter.key()->index, iter.value()); - } setValueAt(i, columns - 1, c->constant); } @@ -490,10 +486,7 @@ qreal QSimplex::solver(SolverFactor factor) // Set new objective in the first row of the simplex matrix qreal resultOffset = 0; - QHash::const_iterator iter; - for (iter = objective->variables.constBegin(); - iter != objective->variables.constEnd(); - ++iter) { + for (auto iter = objective->variables.cbegin(); iter != objective->variables.cend(); ++iter) { // Check if the variable was removed in the simplification process. // If so, we save its offset to the objective function and skip adding @@ -594,8 +587,7 @@ bool QSimplex::simplifyConstraints(QList *constraints) } // Replace known values among their variables - QHash::const_iterator r; - for (r = results.constBegin(); r != results.constEnd(); ++r) { + for (auto r = results.cbegin(); r != results.cend(); ++r) { if (c->variables.contains(r.key())) { c->constant -= r.value() * c->variables.take(r.key()); modified = true; @@ -630,10 +622,8 @@ void QSimplexConstraint::invert() constant = -constant; ratio = Ratio(2 - ratio); - QHash::iterator iter; - for (iter = variables.begin(); iter != variables.end(); ++iter) { + for (auto iter = variables.begin(); iter != variables.end(); ++iter) iter.value() = -iter.value(); - } } QT_END_NAMESPACE diff --git a/src/widgets/graphicsview/qsimplex_p.h b/src/widgets/graphicsview/qsimplex_p.h index f3efa2eb191..c45e728ccf9 100644 --- a/src/widgets/graphicsview/qsimplex_p.h +++ b/src/widgets/graphicsview/qsimplex_p.h @@ -65,8 +65,7 @@ struct QSimplexConstraint bool isSatisfied() { qreal leftHandSide(0); - QHash::const_iterator iter; - for (iter = variables.constBegin(); iter != variables.constEnd(); ++iter) { + for (auto iter = variables.cbegin(); iter != variables.cend(); ++iter) { leftHandSide += iter.value() * iter.key()->result; } @@ -90,8 +89,7 @@ struct QSimplexConstraint QString result; result += QString::fromLatin1("-- QSimplexConstraint %1 --").arg(quintptr(this), 0, 16); - QHash::const_iterator iter; - for (iter = variables.constBegin(); iter != variables.constEnd(); ++iter) { + for (auto iter = variables.cbegin(); iter != variables.cend(); ++iter) { result += QString::fromLatin1(" %1 x %2").arg(iter.value()).arg(quintptr(iter.key()), 0, 16); }