Skip to content

Commit 01aeae1

Browse files
author
codelogicws
committed
refactoring SelectionSort
1 parent 7bfbb04 commit 01aeae1

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed
Binary file not shown.

src/ws/codelogic/algorithms/sort/Element.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ public void set(Element toBeCopiedElement) {
2626
index = toBeCopiedElement.index;
2727
value = toBeCopiedElement.value;
2828
}
29+
2930
}

src/ws/codelogic/algorithms/sort/SelectionSort.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void sort() {
2121

2222
private void replaceWithSmallestUnsorted(){
2323
findSmallest();
24-
exchangeCurrentWithLowest(stage.index);
24+
exchangeCurrentWithLowest();
2525
}
2626

2727
private void findSmallest(){
@@ -40,9 +40,9 @@ private void handleSmallerValues() {
4040
}
4141
}
4242

43-
private void exchangeCurrentWithLowest(int selected) {
44-
array[lowest.index] = array[selected];
45-
array[selected] = lowest.value;
43+
private void exchangeCurrentWithLowest() {
44+
array[stage.index] = lowest.value;
45+
array[lowest.index] = stage.value;
4646
}
4747

4848
public Comparable[] getArray() {

0 commit comments

Comments
 (0)