Class CoordinateTracker
Efficiently tracks a set of Coordinates.
Inheritance
Inherited Members
Namespace: SudokuSpice
Assembly: SudokuSpice.dll
Syntax
public class CoordinateTracker
Remarks
This swaps coordinates within an internal array to provide O(1) tracking and untracking
operations. It also provides immediate, copy-free access to tracked coordinates using a
ReadOnlySpan
.
Constructors
| Improve this Doc View SourceCoordinateTracker(CoordinateTracker)
Copy-constructor to provide a copy of the given CoordinateTracker.
Declaration
public CoordinateTracker(CoordinateTracker existing)
Parameters
Type | Name | Description |
---|---|---|
CoordinateTracker | existing |
CoordinateTracker(Int32)
Constructs a CoordinateTracker
to track coordinates within a
size
-by-size
square.
Declaration
public CoordinateTracker(int size)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | The side length of a square of valid coordinates. |
Properties
| Improve this Doc View SourceNumTracked
The number of coordinates currently considered to be 'tracked'.
Declaration
public int NumTracked { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Size
Declaration
public int Size { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
TrackedCoords
Provides readonly access to the currently tracked Coordinates.
Declaration
public ReadOnlySpan<Coordinate> TrackedCoords { get; }
Property Value
Type | Description |
---|---|
System.ReadOnlySpan<Coordinate> |
Methods
| Improve this Doc View SourceAdd(Coordinate)
Adds and tracks a previously unknown Coordinate. This must only be called once for any given Coordinate.
Declaration
public void Add(in Coordinate c)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | c | The Coordinate to add. |
AddOrTrackIfUntracked(Coordinate)
Ensures a given Coordinate is both added and tracked. Useful when callers
are not certain of the status of the given Coordinate
.
Declaration
public CoordinateTracker.AddOrTrackResult AddOrTrackIfUntracked(in Coordinate c)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | c | The Coordinate to track. |
Returns
Type | Description |
---|---|
CoordinateTracker.AddOrTrackResult | The action that was taken. |
Track(Coordinate)
Tracks a currently untracked Coordinate. The coordinate must not be tracked already.
Declaration
public void Track(in Coordinate c)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | c | The Coordinate to track. |
Untrack(Coordinate)
Untracks a given Coordinate. The Coordinate
must be currently
tracked.
Declaration
public void Untrack(in Coordinate c)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | c | The Coordinate to untrack. |
UntrackAll()
Untracks all Coordinates.
Declaration
public void UntrackAll()