Exemple #1
0
const std::vector<Field*> Sudoku::getRowElements(const Field* refField) const
{
	int step = 1;
	std::vector<Field*> row = getRowElements(step);
	while (!::find(refField,&row))
		row = getRowElements(step++);
	return row;
}
Exemple #2
0
std::vector<int> Sudoku::removeConflictValues(const Field* refField) const
{
	std::vector<int> refreshedVec(comparisonVector);
	const std::vector<Field*> colWhereFieldResides = getColElements(refField);
	const std::vector<Field*> rowWhereFieldResides = getRowElements(refField);
	const std::vector<Field*> gridWhereFieldResides = getGridElements(refField);
	std::vector<int>::const_iterator it = refreshedVec.cbegin();
	while(it != refreshedVec.cend())
	{
		if (::find(*it,&colWhereFieldResides) || ::find(*it,&rowWhereFieldResides) || ::find(*it,&gridWhereFieldResides))
			it = refreshedVec.erase(it);
		else it++;
	}
	return refreshedVec;
	
}
Exemple #3
0
/*----------------------------------------
	Check if Sudoku row number N
	is violated. 
-----------------------------------------*/
bool Sudoku::checkRowViolation(const int rowNum) const
{
	std::vector<int> renewedComparisonVector(comparisonVector);
	std::vector<Field*> mainRow;
	mainRow = getRowElements(rowNum);
	for (std::vector<Field*>::const_iterator cit = mainRow.cbegin();
		 cit!=mainRow.cend();
		 cit++)
	{
		if (!find((*cit)->userAttemptedValue,renewedComparisonVector))
			return true;
	}


	return false;

}
Exemple #4
0
	 double *getMutableRowElements(int irow){
		 // using const_cast to stop warnings about cast-away constness
		 return const_cast<double *>(getRowElements(irow));
	 }
Exemple #5
0
const Field* Sudoku::getField(int rowNum,int colNum) const
{
	std::vector<Field*> row = getRowElements(rowNum);
	return row[colNum-1];
}