Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
dancing_links_t Class Reference

#include <dancing_links.hpp>

Inheritance diagram for dancing_links_t:

Public Member Functions

 dancing_links_t (std::size_t row_count, std::size_t column_count)
void set (std::size_t row, std::size_t col, char color=0)
void set_secondary_column (std::size_t col)
template<typename ResultCallback, typename SearchHeuristic>
std::size_t search (std::size_t max_solutions, ResultCallback callback, SearchHeuristic heuristic)
std::size_t search (std::size_t max_solutions)

Detailed Description

Definition at line 89 of file dancing_links.hpp.

Constructor & Destructor Documentation

◆ dancing_links_t()

dancing_links_t ( std::size_t row_count,
std::size_t column_count )

Definition at line 92 of file dancing_links.hpp.

Member Function Documentation

◆ set()

void set ( std::size_t row,
std::size_t col,
char color = 0 )

Establishes a 1-node at the intersection of [ row, col ].

Parameters
rowThe row in which the node will be set
colThe column in which the node will be set
colorThe color of the node
Precondition
You must start with the top-left node and work to the right, then down, when setting nodes in the matrix. i.e., This must be the right-bottom-most node you have set to this point.

Definition at line 102 of file dancing_links.hpp.

◆ set_secondary_column()

void set_secondary_column ( std::size_t col)

Secondary columns take dancing links to the next step, in that they allow for a column to be optionally used zero or one times. This essentially allows for a condition that can be met once but no more than once.

Parameters
colThe column which will be made secondary

Definition at line 106 of file dancing_links.hpp.

◆ search() [1/2]

template<typename ResultCallback, typename SearchHeuristic>
std::size_t search ( std::size_t max_solutions,
ResultCallback callback,
SearchHeuristic heuristic )

Performs a search looking for solutions to the 1-cover problem. When a solution is found the callback is called once for every row in the solution. The signature for the callback is:

void (*ResultCallback)(std::size_t row, bool last_row_in_solution);
Parameters
max_solutionsMaximum number of solutions to find before breaking out of the search.
callbackcallback
heuristicThe search heuristic to use
Returns
the number of solutions actually found

Definition at line 109 of file dancing_links.hpp.

◆ search() [2/2]

std::size_t search ( std::size_t max_solutions)

Performs a search looking for solutions to the 1-cover problem.

Parameters
max_solutionsMaximum number of solutions to find before breaking out of the search.
Returns
the number of solutions actually found

Definition at line 120 of file dancing_links.hpp.