public class DancingLinks<ColumnName> extends Object
限定符和类型 | 类和说明 |
---|---|
static interface |
DancingLinks.SolutionAcceptor<ColumnName>
Applications should implement this to receive the solutions to their
problems.
|
构造器和说明 |
---|
DancingLinks() |
限定符和类型 | 方法和说明 |
---|---|
void |
addColumn(ColumnName name)
Add a column to the table
|
void |
addColumn(ColumnName name,
boolean primary)
Add a column to the table
|
void |
addRow(boolean[] values)
Add a row to the table.
|
String |
getColumnName(int index)
Get the name of a given column as a string
|
int |
getNumberColumns()
Get the number of columns.
|
int |
solve(DancingLinks.SolutionAcceptor<ColumnName> output)
Solve a complete problem
|
int |
solve(int[] prefix,
DancingLinks.SolutionAcceptor<ColumnName> output)
Given a prefix, find solutions under it.
|
List<int[]> |
split(int depth)
Generate a list of row choices to cover the first moves.
|
public void addColumn(ColumnName name, boolean primary)
name
- The name of the column, which will be returned as part of
solutionsprimary
- Is the column required for a solution?public void addColumn(ColumnName name)
name
- The name of the column, which will be included in the solutionpublic int getNumberColumns()
public String getColumnName(int index)
index
- the index of the columnpublic void addRow(boolean[] values)
values
- the columns that are satisfied by this rowpublic List<int[]> split(int depth)
depth
- the length of the prefixes to generatepublic int solve(int[] prefix, DancingLinks.SolutionAcceptor<ColumnName> output)
prefix
- a list of row choices that control which part of the search
tree to exploreoutput
- the output for each solutionpublic int solve(DancingLinks.SolutionAcceptor<ColumnName> output)
output
- the acceptor to receive answersCopyright © 2009 The Apache Software Foundation