📄 selectionsort.java
字号:
package oop;
public class SelectionSort implements Sort {
private SelectionSort(){}
public void sort(int[] array) {
// TODO Auto-generated method stub
for (int i = 0; i < array.length; i++) {
int lowIndex = i;
for (int j = array.length - 1; j > i; j--) {
if (array[j] < array[lowIndex]) {
lowIndex = j;
}
}
Swap.swap(array,i,lowIndex);
}
}
public static Sort getInstance(){//Singleton 最多只产生一个SelectionSort实例
if (ins==null)
return new SelectionSort();
else
return ins;
}
private static Sort ins=null;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -