以下代碼用於快速排序類。在底部,有一種稱爲交換的方法,它應該採用數組並交換數組中的兩個數字。這在Java中可能嗎?換句話說,是否有可能在這種情況下工作的swap(T [],int,int)格式的方法?我希望我的問題有道理。 public class QuickSort {
public static <T extends Comparable<T>> void sort(T[] table)
任何人都可以幫助我找出這種交換方法,它是較大的快速排序程序的一部分嗎?它應該採用一個數組和兩個整數並交換整數指示的索引位置。 private static <T extends Comparable<T>> int partition(T[] table, int first, int last) {
T pivot = table[first];
int up = first