Fixed max 100 column width issue

This commit is contained in:
Gustav Ekner 2022-03-06 20:43:04 +01:00
parent a2514b9e7f
commit c5016a0229
2 changed files with 9 additions and 8 deletions

View File

@ -12,20 +12,20 @@ export default class ShellSort extends Sort {
while (gap > 0) { while (gap > 0) {
// Go and compare all distant element pairs. // Go and compare all distant element pairs.
for (let i = 0; i < (array.length - gap); i += 1) { for (let i = 0; i < (array.length - gap); i += 1) {
let currentIndex = i; let j = i;
let gapShiftedIndex = i + gap; let gapShiftedIndex = i + gap;
while (currentIndex >= 0) { while (j >= 0) {
// Call visiting callback. // Call visiting callback.
this.callbacks.visitingCallback(array[currentIndex]); this.callbacks.visitingCallback(array[j]);
// Compare and swap array elements if needed. // Compare and swap array elements if needed.
if (this.comparator.lessThan(array[gapShiftedIndex], array[currentIndex])) { if (this.comparator.lessThan(array[gapShiftedIndex], array[j])) {
[array[currentIndex], array[gapShiftedIndex]] = [array[gapShiftedIndex], array[currentIndex]]; [array[j], array[gapShiftedIndex]] = [array[gapShiftedIndex], array[j]];
} }
gapShiftedIndex = currentIndex; gapShiftedIndex = j;
currentIndex -= gap; j -= gap;
} }
} }

View File

@ -95,7 +95,8 @@ export default class Heap {
* @param {number} indexTwo * @param {number} indexTwo
*/ */
swap(indexOne, indexTwo) { swap(indexOne, indexTwo) {
[this.heapContainer[indexOne], this.heapContainer[indexTwo]] = [this.heapContainer[indexTwo], this.heapContainer[indexOne]]; [this.heapContainer[indexOne], this.heapContainer[indexTwo]] = [
this.heapContainer[indexTwo], this.heapContainer[indexOne]];
} }
/** /**