mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 18:32:56 +08:00
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:
@ -1,5 +1,7 @@
|
|||||||
package com.thealgorithms.sorts;
|
package com.thealgorithms.sorts;
|
||||||
|
|
||||||
|
import static com.thealgorithms.sorts.SortUtils.swap;
|
||||||
|
|
||||||
public class SelectionSort implements SortAlgorithm {
|
public class SelectionSort implements SortAlgorithm {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,9 +22,7 @@ public class SelectionSort implements SortAlgorithm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (minIndex != i) {
|
if (minIndex != i) {
|
||||||
T temp = arr[i];
|
swap(arr, i, minIndex);
|
||||||
arr[i] = arr[minIndex];
|
|
||||||
arr[minIndex] = temp;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
|
Reference in New Issue
Block a user