Updated postprocess permutation calculation to handle corner cases (topn = 1 and permutations == topn)

This commit is contained in:
Matt Hill
2014-02-19 18:17:35 -06:00
parent a01d170495
commit cc3c4c7861

View File

@@ -357,10 +357,11 @@ vector<int> PostProcess::getMaxDepth(int topn)
int nextLeastDropCharPos = getNextLeastDrop(depth); int nextLeastDropCharPos = getNextLeastDrop(depth);
while (nextLeastDropCharPos != -1) while (nextLeastDropCharPos != -1)
{ {
depth[nextLeastDropCharPos] = depth[nextLeastDropCharPos] + 1; if (getPermutationCount(depth) >= topn)
if (getPermutationCount(depth) > topn)
break; break;
depth[nextLeastDropCharPos] = depth[nextLeastDropCharPos] + 1;
nextLeastDropCharPos = getNextLeastDrop(depth); nextLeastDropCharPos = getNextLeastDrop(depth);
} }