@@ -45,7 +45,7 @@ private static <T extends Comparable<T>> void dualPivotQuicksort(T[] array, int
45
45
*/
46
46
private static <T extends Comparable <T >> int [] partition (T [] array , int left , int right ) {
47
47
if (array [left ].compareTo (array [right ]) > 0 ) {
48
- swap (array , left , right );
48
+ SortUtils . swap (array , left , right );
49
49
}
50
50
51
51
T pivot1 = array [left ];
@@ -58,7 +58,7 @@ private static <T extends Comparable<T>> int[] partition(T[] array, int left, in
58
58
while (less <= great ) {
59
59
// If element is less than pivot1
60
60
if (array [less ].compareTo (pivot1 ) < 0 ) {
61
- swap (array , less , left ++);
61
+ SortUtils . swap (array , less , left ++);
62
62
}
63
63
64
64
// If element is greater or equal to pivot2
@@ -67,10 +67,10 @@ else if (array[less].compareTo(pivot2) >= 0) {
67
67
great --;
68
68
}
69
69
70
- swap (array , less , great --);
70
+ SortUtils . swap (array , less , great --);
71
71
72
72
if (array [less ].compareTo (pivot1 ) < 0 ) {
73
- swap (array , less , left ++);
73
+ SortUtils . swap (array , less , left ++);
74
74
}
75
75
}
76
76
@@ -79,19 +79,13 @@ else if (array[less].compareTo(pivot2) >= 0) {
79
79
j --;
80
80
great ++;
81
81
// Bring the pivots to their appropriate positions
82
- swap (array , left , j );
83
- swap (array , right , great );
82
+ SortUtils . swap (array , left , j );
83
+ SortUtils . swap (array , right , great );
84
84
85
85
// return the pivots' indices
86
86
return new int [] {less , great };
87
87
}
88
88
89
- private static <T extends Comparable <T >> void swap (T [] array , int left , int right ) {
90
- T temp = array [left ];
91
- array [left ] = array [right ];
92
- array [right ] = temp ;
93
- }
94
-
95
89
/**
96
90
* Main method
97
91
*
0 commit comments