Skip to content

Commit 238eec0

Browse files
committed
Updated comments
1 parent e17eaf7 commit 238eec0

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/com/example/algorithmvisualizer/AlgVisualizer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ public void resetSwingWorker(AlgVisualizer alg, Integer[] arr, ArrDisplay displa
247247
}
248248

249249
// Reset the timer on the previous sort that was done, used in the reset()
250-
// method
251250
public void resetTime() {
252251
startTime = 0;
253252
visualizationTime = 0;

src/com/example/algorithmvisualizer/ArrDisplay.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ public void paintComponent(Graphics g) {
5757
swappedIndex1 = -1;
5858
swappedIndex2 = -1;
5959
} else if (!algVisualizer.stopSort()) {
60-
// exclude the first chunk as its used to draw the first array, not related to the sorting
61-
swappedIndex1 = swappedIndexes.get(numChunks)[0]; // index out of bounds exception?
60+
swappedIndex1 = swappedIndexes.get(numChunks)[0];
6261
swappedIndex2 = swappedIndexes.get(numChunks)[1];
6362
}
64-
// Iterate through the array and drawn every index
63+
// Iterate through the array and draw every index
6564
for (int i = 0; i < arr.length; i++) {
6665
int width = (int) (algVisualizer.getWidth() / (double) arr.length);
6766
int height = arr[i] * (algVisualizer.getArrDispHeight() / arr.length);

src/com/example/algorithmvisualizer/ArrSorting.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ private void sleep() {
103103
}
104104
}
105105

106+
/*
107+
* All of the sorting algorithms below are constantly checking in the loops to
108+
* see if sorting has been stopped by a reset. If sorting has been stopped, the
109+
* if statement will be true and the sorting method will be terminated.
110+
*
111+
* After every index comparison, we add +1 to the total number of index
112+
* comparisons.
113+
*
114+
* After every index swap, we add the pair of indexes swapped to the list in
115+
* arrDisplay for them to be drawn. We then call publish() and send a clone of
116+
* the array as a chunk to the process(List<> Chunks) method above, where it
117+
* will be painted in the frame.
118+
*/
119+
106120
private void bubbleSort() {
107121
for (int i = 0; i < n - 1; i++) {
108122
if (algVisualizer.stopSort())

0 commit comments

Comments
 (0)