Show / Hide Table of Contents

Class PuzzleWithPossibleValues

Stores a puzzle's data and associated possible values.

Inheritance
System.Object
PuzzleWithPossibleValues
Implements
IPuzzleWithPossibleValues<PuzzleWithPossibleValues>
IPuzzle<PuzzleWithPossibleValues>
IReadOnlyPuzzleWithMutablePossibleValues
IReadOnlyPuzzleWithPossibleValues
IReadOnlyPuzzle
IPossibleValues
IReadOnlyPossibleValues
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: SudokuSpice.RuleBased
Assembly: SudokuSpice.dll
Syntax
public class PuzzleWithPossibleValues : IPuzzleWithPossibleValues<PuzzleWithPossibleValues>, IPuzzle<PuzzleWithPossibleValues>, IReadOnlyPuzzleWithMutablePossibleValues, IReadOnlyPuzzleWithPossibleValues, IReadOnlyPuzzle, IPossibleValues, IReadOnlyPossibleValues

Constructors

| Improve this Doc View Source

PuzzleWithPossibleValues(Puzzle)

Constructs a puzzle backed by the given Puzzle object, but now with the ability to track possible values.

Declaration
public PuzzleWithPossibleValues(Puzzle puzzle)
Parameters
Type Name Description
Puzzle puzzle

The puzzle data to use. The puzzle maintains a reference to this object.

| Improve this Doc View Source

PuzzleWithPossibleValues(PuzzleWithPossibleValues)

A deep copy constructor for an existing puzzle.

Declaration
public PuzzleWithPossibleValues(PuzzleWithPossibleValues existing)
Parameters
Type Name Description
PuzzleWithPossibleValues existing
| Improve this Doc View Source

PuzzleWithPossibleValues(Int32)

Constructs a new puzzle of the given side length.

Declaration
public PuzzleWithPossibleValues(int size)
Parameters
Type Name Description
System.Int32 size

The side-length for this Sudoku puzzle. Must be in the inclusive range [1, 31].

Exceptions
Type Condition
System.ArgumentException

Thrown if size is not the square of a whole number, or is outside the range [1, 31].

| Improve this Doc View Source

PuzzleWithPossibleValues(Nullable<Int32>[][])

Constructs a new puzzle backed by the given array.

The puzzle is backed directly by this array (i.e. modifying the array modifies the puzzle, and vice-versa). If this is not what you want, see CopyFrom(Nullable<Int32>[,]) and CopyFrom(Nullable<Int32>[][]). Note that all future modifications should be done through this puzzle object, else this will be in an incorrect state.

Declaration
public PuzzleWithPossibleValues(int? [][] puzzleMatrix)
Parameters
Type Name Description
System.Nullable<System.Int32>[][] puzzleMatrix

The data for this Sudoku puzzle. Preset squares should be set, and unset squares should be null. The puzzle maintains a reference to this array.

Properties

| Improve this Doc View Source

AllPossibleValuesSpan

Gets all the possible values for this puzzle.

If a value can be repeated n times in a region, then there should be n instances of it in the span.

Declaration
public ReadOnlySpan<int> AllPossibleValuesSpan { get; }
Property Value
Type Description
System.ReadOnlySpan<System.Int32>
| Improve this Doc View Source

CountPerUniqueValue

The count of times each unique value is expected to be included in a region.

Declaration
public IReadOnlyDictionary<int, int> CountPerUniqueValue { get; }
Property Value
Type Description
System.Collections.Generic.IReadOnlyDictionary<System.Int32, System.Int32>
| Improve this Doc View Source

Item[Coordinate]

Provides read and write access to a Sudoku puzzle.

Declaration
public int? this[in Coordinate c] { get; set; }
Parameters
Type Name Description
Coordinate c

The location of the square to get/set the value of.

Property Value
Type Description
System.Nullable<System.Int32>

The value of the square at c

| Improve this Doc View Source

Item[Int32, Int32]

Gets or sets the current value of a given square. A square can be 'unset' by setting its value to null.

Declaration
public int? this[int row, int col] { get; set; }
Parameters
Type Name Description
System.Int32 row
System.Int32 col
Property Value
Type Description
System.Nullable<System.Int32>
| Improve this Doc View Source

NumEmptySquares

Provides read-only access to a puzzle's data.

Declaration
public int NumEmptySquares { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

NumSetSquares

Provides read-only access to a puzzle's data.

Declaration
public int NumSetSquares { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

NumSquares

Provides read-only access to a puzzle's data.

Declaration
public int NumSquares { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Size

Provides read-only access to a puzzle's data.

Declaration
public int Size { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

UniquePossibleValues

Provides read-only access to a puzzle's data.

Declaration
public BitVector UniquePossibleValues { get; }
Property Value
Type Description
BitVector

Methods

| Improve this Doc View Source

CopyFrom(Nullable<Int32>[][])

Creates a new puzzle with a copy of the given matrix.

Declaration
public static PuzzleWithPossibleValues CopyFrom(int? [][] matrix)
Parameters
Type Name Description
System.Nullable<System.Int32>[][] matrix
Returns
Type Description
PuzzleWithPossibleValues
| Improve this Doc View Source

CopyFrom(Nullable<Int32>[,])

Creates a new puzzle with a copy of the given matrix.

Declaration
public static PuzzleWithPossibleValues CopyFrom(int? [, ] matrix)
Parameters
Type Name Description
System.Nullable<System.Int32>[,] matrix
Returns
Type Description
PuzzleWithPossibleValues
| Improve this Doc View Source

DeepCopy()

Creates a deep-copy of this puzzle.

Declaration
public PuzzleWithPossibleValues DeepCopy()
Returns
Type Description
PuzzleWithPossibleValues
| Improve this Doc View Source

GetPossibleValues(Coordinate)

Gets the current possible values for a given coordinate.

If the value is already set for the given coordinate, the result is undefined.

Declaration
public BitVector GetPossibleValues(in Coordinate c)
Parameters
Type Name Description
Coordinate c
Returns
Type Description
BitVector
| Improve this Doc View Source

GetUnsetCoords()

Gets a span of coordinates for all the unset squares.

Declaration
public ReadOnlySpan<Coordinate> GetUnsetCoords()
Returns
Type Description
System.ReadOnlySpan<Coordinate>
| Improve this Doc View Source

IntersectPossibleValues(Coordinate, BitVector)

Modifies the possible values for a square to be the intersect of the current possible values and the given possibleValues.

Declaration
public void IntersectPossibleValues(in Coordinate c, BitVector possibleValues)
Parameters
Type Name Description
Coordinate c
BitVector possibleValues
| Improve this Doc View Source

ResetPossibleValues(Coordinate)

Resets the possible values at the given location to be all possible values for this puzzle.

Declaration
public void ResetPossibleValues(in Coordinate c)
Parameters
Type Name Description
Coordinate c
| Improve this Doc View Source

SetPossibleValues(Coordinate, BitVector)

Sets the possible values for a square.

Declaration
public void SetPossibleValues(in Coordinate c, BitVector possibleValues)
Parameters
Type Name Description
Coordinate c
BitVector possibleValues
| Improve this Doc View Source

ToString()

Returns the puzzle in a pretty string format, with boxes and rows separated by pipes and dashes.

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()

Implements

IPuzzleWithPossibleValues<T>
IPuzzle<T>
IReadOnlyPuzzleWithMutablePossibleValues
IReadOnlyPuzzleWithPossibleValues
IReadOnlyPuzzle
IPossibleValues
IReadOnlyPossibleValues
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX