refactor: use method SortUtils.swap
(#4946)
* refactor: use method SortUtils.swap * fix: clang format * style: explicitly import `swap` --------- Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This commit is contained in:
parent
945e7b56bb
commit
e5f3d232c9
@ -1,5 +1,7 @@
|
||||
package com.thealgorithms.sorts;
|
||||
|
||||
import static com.thealgorithms.sorts.SortUtils.swap;
|
||||
|
||||
public class SelectionSort implements SortAlgorithm {
|
||||
|
||||
/**
|
||||
@ -20,9 +22,7 @@ public class SelectionSort implements SortAlgorithm {
|
||||
}
|
||||
}
|
||||
if (minIndex != i) {
|
||||
T temp = arr[i];
|
||||
arr[i] = arr[minIndex];
|
||||
arr[minIndex] = temp;
|
||||
swap(arr, i, minIndex);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
|
Loading…
Reference in New Issue
Block a user