Documentation
¶
Index ¶
- Variables
- func BuildDLX(itemsCount int, options <-chan SparseRow, isSecondaryColumn func(int) bool) ([]Column, []Node)
- func BuildDLXAsNeeded(ctx context.Context, matrixChan <-chan WordOption, ...) (*column, error)
- func Cover(col *column) bool
- func FindRowIndex(matrix SparseMatrix, row SparseRow) (int, bool)
- func InitializeRoot() *column
- func SolveDLX(ctx context.Context, matrix SparseMatrix, tickerPeriod time.Duration) <-chan Solution
- func SolveDLXWithChannel(ctx context.Context, matrixChan <-chan WordOption, tickerPeriod time.Duration) <-chan Solution
- func SolveDLXWithChannelAndSecondary(ctx context.Context, matrixChan <-chan WordOption, ...) <-chan Solution
- func SolveDLXWithSecondary(ctx context.Context, matrix SparseMatrix, isSecondaryColumn func(int) bool, ...) <-chan Solution
- func SolveExactCover(ctx context.Context, columns []Column, nodes []Node, solution []AppInt, ...) error
- func Uncover(col *column)
- type AppInt
- type Column
- type Node
- type NodeVisitor
- type Solution
- type SparseMatrix
- type SparseRow
- type WordOption
Constants ¶
This section is empty.
Variables ¶
var ThematicColsForPrimaryColsIDX map[int][]*column
Functions ¶
func BuildDLXAsNeeded ¶ added in v0.5.0
func BuildDLXAsNeeded(ctx context.Context, matrixChan <-chan WordOption, isSecondaryColumn func(int) bool) (*column, error)
BuildDLXAsNeeded constructs the Dancing Links structure from the sparse matrix by creating columns lazily (on-demand) as rows are processed. It listens for context cancellation and terminates early if the context is canceled. Returns the root column and an error if the context was canceled.
func Cover ¶
func Cover(col *column) bool
Cover removes a column from the header list and primary columns list
func FindRowIndex ¶
func FindRowIndex(matrix SparseMatrix, row SparseRow) (int, bool)
findRowIndex returns the index of the row in the matrix that matches the given row slice.
func InitializeRoot ¶
func InitializeRoot() *column
InitializeRoot creates and initializes the root header
func SolveDLX ¶
func SolveDLX( ctx context.Context, matrix SparseMatrix, tickerPeriod time.Duration, ) <-chan Solution
SolveDLX initiates the DLX search and returns a channel of solutions (each a SparseMatrix).
func SolveDLXWithChannel ¶ added in v0.5.0
func SolveDLXWithChannelAndSecondary ¶ added in v0.5.1
func SolveDLXWithSecondary ¶
func SolveDLXWithSecondary( ctx context.Context, matrix SparseMatrix, isSecondaryColumn func(int) bool, tickerPeriod time.Duration, ) <-chan Solution
SolveDLXWithSecondary initiates the DLX search with secondary columns and returns a channel of solutions (each a SparseMatrix).
Types ¶
type AppInt ¶ added in v0.9.0
type AppInt int32
AppInt is the base integer type used throughout the application
type NodeVisitor ¶
type NodeVisitor func(depth int)
NodeVisitor is called at each depth for debugging or counting
type Solution ¶ added in v0.7.0
type Solution struct { IsFinal bool Matrix SparseMatrix }
Solution represents a solution with a flag indicating if it's final.
type SparseMatrix ¶ added in v0.4.1
type SparseMatrix []SparseRow
func SparseMatrixFromArray ¶ added in v0.4.1
func SparseMatrixFromArray(matrix [][]int) SparseMatrix
Helper function to convert a 2D array of ints to a SparseMatrix
type SparseRow ¶ added in v0.4.1
Type definitions for SparseRow, SparseMatrix, and Solution
func RebuildRowFromNode ¶ added in v0.5.0
func RebuildRowFromNode(n *node) SparseRow