public class InsertionSort {
public static <T extends Comparable<T>> void sort(T[] array) {
for (int indexOfNextToInsert = 1; indexOfNextToInsert < array.length; indexOfNextToInsert++) {
// array from array[0] to array[indexOfNextItemToReposition - 1] is sorted
// now insert array item at "indexOfNextItemToReposition" into
// the sorted left side of array
insert(array, indexOfNextToInsert);
}
}
private static <T extends Comparable<T>> void insert(T[] array, int indexOfNextToInsert) {
T nextValue = array[indexOfNextToInsert];
while (indexOfNextToInsert > 0 && nextValue.compareTo(array[indexOfNextToInsert - 1]) < 0) {
array[indexOfNextToInsert] = array[indexOfNextToInsert - 1];
indexOfNextToInsert--; //<-- I am getting an warning here in eclipse
}
array[indexOfNextToInsert] = nextValue;
}
}
誰かがこの警告を修正する方法を知っていますか?