Simplified selectColumnSizeHeuristic
This commit is contained in:
parent
da1405f262
commit
5ccbb2ef1c
@ -33,18 +33,13 @@ type SolutionCallback = (output: DNode[]) => boolean;
|
|||||||
type ColumnSelector = (header: CNode) => CNode;
|
type ColumnSelector = (header: CNode) => CNode;
|
||||||
|
|
||||||
function selectColumnSizeHeuristic(header: CNode): CNode {
|
function selectColumnSizeHeuristic(header: CNode): CNode {
|
||||||
let minSize = Infinity;
|
let minColumn = header.right;
|
||||||
let minColumn: CNode | undefined;
|
let curColumn = minColumn;
|
||||||
let curColumn = header;
|
|
||||||
while ((curColumn = curColumn.right) !== header) {
|
while ((curColumn = curColumn.right) !== header) {
|
||||||
if (curColumn.column.size < minSize) {
|
if (curColumn.size < minColumn.size) {
|
||||||
minSize = curColumn.column.size;
|
|
||||||
minColumn = curColumn;
|
minColumn = curColumn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!minColumn) {
|
|
||||||
throw new Error("minColumn is undefined, this shouldn't be possible.");
|
|
||||||
}
|
|
||||||
return minColumn;
|
return minColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user