本文整理汇总了C++中MoveList::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ MoveList::isEmpty方法的具体用法?C++ MoveList::isEmpty怎么用?C++ MoveList::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveList
的用法示例。
在下文中一共展示了MoveList::isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solutionCount
int AbstractGrid::solutionCount()
{
MoveList possibleNextMoves;
// TODO: put following in external function
foreach (AbstractCell *cell, m_cells) {
if (!cell->hasBeenMoved()) {
Directions dirs = cell->cables();
Move move;
if (dirs == None) {
// no cables
move = Move(cell->index(), Move::None);
possibleNextMoves.append(move);
} else if (dirs == (Up | Down) || dirs == (Left | Right)) {
// cables forming a line
move = Move(cell->index(), Move::None);
possibleNextMoves.append(move);
move = Move(cell->index(), Move::Left);
possibleNextMoves.append(move);
} else {
// other kind of cables
move = Move(cell->index(), Move::None);
possibleNextMoves.append(move);
move = Move(cell->index(), Move::Left);
possibleNextMoves.append(move);
move = Move(cell->index(), Move::Right);
possibleNextMoves.append(move);
move = Move(cell->index(), Move::Inverted);
possibleNextMoves.append(move);
}
break;
}
}
// all cells have been moved
if (possibleNextMoves.isEmpty()) {
return isPossibleSolution() ? 1 : 0;
}
// else
int solutionsFound = 0;
foreach (const Move &nextMove, possibleNextMoves) {
int index = nextMove.index();
switch (nextMove.move()) {
case Move::None:
m_cells[index]->emptyMove();
break;
case Move::Right:
m_cells[index]->rotateClockwise();
break;
case Move::Left:
m_cells[index]->rotateCounterclockwise();
break;
case Move::Inverted:
m_cells[index]->invert();
break;
}
if (movesDoneArePossible()) {
solutionsFound += solutionCount(); // recursive call
}
m_cells[index]->reset(); // undo move
}