Commit 6a7a8b0a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

We can use std::as_const

parent 73a7f092
......@@ -124,7 +124,7 @@ int CageGenerator::makeCages (SKGraph * graph, QList<int> * solutionMoves,
int cageValue;
int chosenSize;
int index = -1;
for (const int n : qAsConst(mUnusedCells)) {
for (const int n : std::as_const(mUnusedCells)) {
switch (mNeighbourFlags.at (n)){
case 7:
case 11:
......@@ -198,7 +198,7 @@ int CageGenerator::makeCages (SKGraph * graph, QList<int> * solutionMoves,
#ifdef MATHDOKU_LOG
qCDebug(KSudokuLog) << "CAGE" << mGraph->cageCount() << cage;
char tag = 'a' + mGraph->cageCount() - 1;
for (const int cell : qAsConst(cage)) {
for (const int cell : std::as_const(cage)) {
usedCells[cell] = tag;
}
qCDebug(KSudokuLog) << "LAYOUT" << tag << usedCells;
......@@ -211,7 +211,7 @@ int CageGenerator::makeCages (SKGraph * graph, QList<int> * solutionMoves,
fprintf (stderr, "\n");
#endif
QList<int> flagsList;
for (const int cell : qAsConst(mUnusedCells)) {
for (const int cell : std::as_const(mUnusedCells)) {
flagsList.append (mNeighbourFlags.at (cell));
}
#ifdef MATHDOKU_LOG
......@@ -369,7 +369,7 @@ QVector<int> CageGenerator::makeOneCage (int seedCell, int requiredSize)
// Pick a neighbour to be added to the cage.
index = -1;
for (const int unb : qAsConst(unusedNeighbours)) {
for (const int unb : std::as_const(unusedNeighbours)) {
flags = mNeighbourFlags.at (unb);
if (flags == 15) {
// Choose a cell that has been surrounded and isolated.
......
......@@ -166,7 +166,7 @@ void DLXSolver::recordSolution (const int solutionNum, QList<DLXNode *> & soluti
}
}
else { // Sudoku or Roxdoku variant.
for (DLXNode * node : qAsConst(solution)) {
for (DLXNode * node : std::as_const(solution)) {
int rowNumDLX = node->value;
mBoardValues [rowNumDLX/order] = (rowNumDLX % order) + 1;
}
......@@ -310,7 +310,7 @@ int DLXSolver::solveSudoku (SKGraph * graph, const BoardContents & boardValues,
}
// Create the initial set of columns.
for (DLXNode * colDLX : qAsConst(mColumns)) {
for (DLXNode * colDLX : std::as_const(mColumns)) {
mEndColNum++;
// If the constraint is not excluded, put an empty column in the matrix.
if (colDLX != 0) {
......@@ -558,7 +558,7 @@ int DLXSolver::solveDLX (int solutionLimit)
solution.append (currNode);
#ifdef DLX_LOG
fprintf (stderr, "CURRENT SOLUTION: %d rows:", solution.size());
for (DLXNode * q : qAsConst(solution)) {
for (DLXNode * q : std::as_const(solution)) {
fprintf (stderr, " %d", q->value);
}
fprintf (stderr, "\n");
......
......@@ -196,7 +196,7 @@ void KSudoku::updateShapesList()
QString variantDataPath;
QString variantIcon;
for (const QFileInfo &configFileInfo : qAsConst(filepaths)) {
for (const QFileInfo &configFileInfo : std::as_const(filepaths)) {
const QDir variantDir = configFileInfo.dir();
KConfig variantConfig(configFileInfo.filePath(), KConfig::SimpleConfig);
KConfigGroup group = variantConfig.group ("KSudokuVariant");
......
......@@ -541,7 +541,7 @@ void View2DScene::setSceneSize(const QSize& size) {
m_cells[i]->resize(grid);
}
for (ksudoku::GroupGraphicsItem* group : qAsConst(m_groups)) {
for (ksudoku::GroupGraphicsItem* group : std::as_const(m_groups)) {
group->resize(grid, m_highlightsOn);
}
......@@ -552,7 +552,7 @@ void View2DScene::hover(int cell) {
m_cursorPos = cell;
// qCDebug(KSudokuLog) << "hover cell" << cell << m_cells[cell];
QPoint pos(m_cells[cell]->pos());
for (GroupGraphicsItem* item : qAsConst(m_groups)) {
for (GroupGraphicsItem* item : std::as_const(m_groups)) {
item->setHighlight(pos, m_highlightsOn);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment