Show / Hide Table of Contents

Class CoordinateTracker

Efficiently tracks a set of Coordinates.

Inheritance
System.Object
CoordinateTracker
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)
System.Object.ToString()
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 Source

CoordinateTracker(CoordinateTracker)

Copy-constructor to provide a copy of the given CoordinateTracker.

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

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 Source

NumTracked

The number of coordinates currently considered to be 'tracked'.

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

Size

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

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 Source

Add(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

UntrackAll()

Untracks all Coordinates.

Declaration
public void UntrackAll()
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX