Skip to content

Commit

Permalink
fix combine backwards
Browse files Browse the repository at this point in the history
  • Loading branch information
MusicTheorist committed Oct 24, 2021
1 parent b367919 commit 18fd1ae
Showing 1 changed file with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1575,23 +1575,18 @@ private void combineBackwards(T[] array, int firstKey, int start, int length, in
if(lastSubarrays != 0) {
int offset = start + (fullMerges * mergeLen);

if(lastSubarrays - subarrayLen <= blockLen) {
mergeBackwards(array, offset, subarrayLen, lastSubarrays - subarrayLen, blockLen, cmp);
}
else {
sortBlocks(array, firstKey, offset, blockCount, leftBlocks, blockLen, true, cmp);
sortBlocks(array, firstKey, offset, blockCount, leftBlocks, blockLen, true, cmp);

int lastFragment = lastSubarrays - (blockCount * blockLen);
int lastFragment = lastSubarrays - (blockCount * blockLen);

this.mergeBlocksBackwards(array, firstKey, medianKey, offset, blockCount, blockLen,
lastFragment, cmp);
this.mergeBlocksBackwards(array, firstKey, medianKey, offset, blockCount, blockLen,
lastFragment, cmp);

//TODO: Why is this 'blockCount + 1'???
// We believe this '+ 1' is unnecessary and
// possibly has a *hilarious* origin story
sortKeys(array, firstKey, medianKey, blockCount, offset, cmp);
//insertSort(array, firstKey, blockCount, cmp);
}
//TODO: Why is this 'blockCount + 1'???
// We believe this '+ 1' is unnecessary and
// possibly has a *hilarious* origin story
sortKeys(array, firstKey, medianKey, blockCount, offset, cmp);
//insertSort(array, firstKey, blockCount, cmp);
}

blockCount = mergeLen / blockLen;
Expand Down

0 comments on commit 18fd1ae

Please sign in to comment.