Simplified selectColumnSizeHeuristic

This commit is contained in:
Matt Low 2021-02-25 00:49:41 -07:00
parent 1ff71d099e
commit 3c6d69c343

View File

@ -33,18 +33,13 @@ type SolutionCallback = (output: DNode[]) => boolean;
type ColumnSelector = (header: CNode) => CNode;
function selectColumnSizeHeuristic(header: CNode): CNode {
let minSize = Infinity;
let minColumn: CNode | undefined;
let curColumn = header;
let minColumn = header.right;
let curColumn = minColumn;
while ((curColumn = curColumn.right) !== header) {
if (curColumn.column.size < minSize) {
minSize = curColumn.column.size;
if (curColumn.size < minColumn.size) {
minColumn = curColumn;
}
}
if (!minColumn) {
throw new Error("minColumn is undefined, this shouldn't be possible.");
}
return minColumn;
}