Added a few convenience methods.

This commit is contained in:
Axel Dörfler 2012-06-06 00:34:51 +02:00
parent bea2387b68
commit 0ba36860ad
2 changed files with 25 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2007-2010, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2007-2012, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@ -280,6 +280,13 @@ SudokuField::HintMaskAt(uint32 x, uint32 y) const
}
bool
SudokuField::HasHint(uint32 x, uint32 y, uint32 value) const
{
return (_FieldAt(x, y).hint_mask & (1UL << (value - 1))) != 0;
}
void
SudokuField::SetValidMaskAt(uint32 x, uint32 y, uint32 validMask)
{
@ -294,6 +301,13 @@ SudokuField::ValidMaskAt(uint32 x, uint32 y) const
}
bool
SudokuField::IsValid(uint32 x, uint32 y, uint32 value) const
{
return (_FieldAt(x, y).valid_mask & (1UL << (value - 1))) != 0;
}
void
SudokuField::SetFlagsAt(uint32 x, uint32 y, uint32 flags)
{
@ -308,6 +322,13 @@ SudokuField::FlagsAt(uint32 x, uint32 y) const
}
bool
SudokuField::IsInitialValue(uint32 x, uint32 y) const
{
return (_FieldAt(x, y).flags & kInitialValue) != 0;
}
void
SudokuField::SetValueAt(uint32 x, uint32 y, uint32 value, bool setSolved)
{

View File

@ -41,13 +41,16 @@ public:
void SetHintMaskAt(uint32 x, uint32 y,
uint32 hintMask);
uint32 HintMaskAt(uint32 x, uint32 y) const;
bool HasHint(uint32 x, uint32 y, uint32 value) const;
void SetValidMaskAt(uint32 x, uint32 y,
uint32 validMask);
uint32 ValidMaskAt(uint32 x, uint32 y) const;
bool IsValid(uint32 x, uint32 y, uint32 value) const;
void SetFlagsAt(uint32 x, uint32 y, uint32 flags);
uint32 FlagsAt(uint32 x, uint32 y) const;
bool IsInitialValue(uint32 x, uint32 y) const;
void SetValueAt(uint32 x, uint32 y, uint32 value,
bool setSolved = false);