Skip to content

Commit c88081c

Browse files
committed
REX + ProgressBar polishing
1 parent eb44a17 commit c88081c

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/algorithms/controllers/MSDRadixSort.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ arr],
453453
msdRadixSortRecursive(arr, mid, right, mask - 1, depth + 1)
454454
partitionChunker(MSD_BOOKMARKS.sort_right, undefined, undefined, undefined, undefined, left, right, depth, arr, mask)
455455

456+
} else {
457+
// stop at Done line just for base case
458+
// XXX (better to do it always???)
459+
chunker.add(MSD_BOOKMARKS.done, (vis) => {}, [], depth);
456460
}
457461
// After the recursive call, we need to pop from the real stack to go back up one
458462
finished_stack_frames.push(real_stack.pop());
@@ -552,7 +556,7 @@ arr],
552556
)
553557
msdRadixSortRecursive(A, 0, n-1, mask, 0);
554558

555-
chunker.add(MSD_BOOKMARKS.done,
559+
chunker.add(MSD_BOOKMARKS.top_call,
556560
vis => {
557561
vis.array.setStackDepth(0)
558562
for (let k = 0; k < n; k++) {

src/algorithms/pseudocode/MSDRadixSort.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ should be the same for all data in the array segment.
5151
\\Expl}
5252
Sort Right Part \\Ref MSDRadixSortRight
5353
\\Expl{ Sort elements with 1 mask bit: A[i]..A[right]
54+
(then return from this RexsortRecursive call).
5455
\\Expl}
5556
\\In}
5657
// Done \\B 5000
58+
\\Expl{ We stop at this line for the base case of the recursion.
59+
\\Expl}
5760
\\Code}
5861
5962
\\Code{

src/components/mid-panel/ProgressBar.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ class ProgressBar extends React.Component {
159159
setProgress(node.rectPrimary, parseFloat(current / max, 10));
160160
setBuffer(node.buffer, 1);
161161
setThumb(node.thumb, parseFloat(current / max, 10));
162-
162+
// For some weird reason the "current" chunk number overshoots for
163+
// the last chunk so we a a fudge here (also, max is one more than the
164+
// number of chunks)
165+
let curr = (current === max? max - 1: current);
163166

164167
return (
165168
<div
@@ -173,11 +176,7 @@ class ProgressBar extends React.Component {
173176
<div className="progressLable" id="progressLabel">
174177
<div className="innerText">
175178
{
176-
// if the user enters a valid input and clicks on LOAD
177-
// the progress bar displays the percentage of progress
178-
// convert the lines of code to percentge by multiplying the division by 100
179-
`Progress: ${"" + current + "/" + max + "=" + Math.round((current / max) * 100, 2)}%`
180-
// if the user does not enter a valid input, initialise the progress bar as not loaded
179+
"Progress:" + curr + "/" + (max-1) + "=" + Math.round((curr / (max-1)) * 100, 2) + "%"
181180
}
182181
</div>
183182
</div>

0 commit comments

Comments
 (0)