From 0ba36860ad2973704cf0e53e5a37f944882261de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 6 Jun 2012 00:34:51 +0200 Subject: [PATCH] Added a few convenience methods. --- src/apps/sudoku/SudokuField.cpp | 23 ++++++++++++++++++++++- src/apps/sudoku/SudokuField.h | 3 +++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/apps/sudoku/SudokuField.cpp b/src/apps/sudoku/SudokuField.cpp index a139d473b9..f1ff6bc89b 100644 --- a/src/apps/sudoku/SudokuField.cpp +++ b/src/apps/sudoku/SudokuField.cpp @@ -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) { diff --git a/src/apps/sudoku/SudokuField.h b/src/apps/sudoku/SudokuField.h index 2b0bbf6fe9..ace2647818 100644 --- a/src/apps/sudoku/SudokuField.h +++ b/src/apps/sudoku/SudokuField.h @@ -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);