@@ -97,48 +97,48 @@ private void writeInterval(int[][] tree, int i, int a, int b, int c, int d) {
9797 }
9898
9999 private void compSwap (int [] array , int [] map , int a , int b ) {
100- if (map [b ] < this .end && Reads .compareIndices (array , map [a ], map [b ], SLEEP , true ) > 0 )
100+ if (map [b ] < this .end && Reads .compareIndices (array , map [a ], map [b ], SLEEP , true ) > 0 )
101101 Writes .swap (array , map [a ], map [b ], SLEEP , false , false );
102102 }
103103
104104 private void smallSort (int [] array , int [] map , int a , int b ) { // creasesort for compactness
105- if (b -a < 2 ) return ;
105+ if (b -a < 2 ) return ;
106106
107107 int n = (1 << 31 -Integer .numberOfLeadingZeros (b -a -1 )) - 1 ;
108108
109- for (int k = 2 *n ; k > 0 ; k /= 2 ) {
110- for (int i = a +1 ; i < b ; i += 2 )
109+ for (int k = 2 *n ; k > 0 ; k /= 2 ) {
110+ for (int i = a +1 ; i < b ; i += 2 )
111111 this .compSwap (array , map , i -1 , i );
112- for (int j = n ; j >= Math .max (k /2 , 1 ); j /= 2 )
113- for (int i = a +1 +j ; i < b ; i += 2 )
112+ for (int j = n ; j >= Math .max (k /2 , 1 ); j /= 2 )
113+ for (int i = a +1 +j ; i < b ; i += 2 )
114114 this .compSwap (array , map , i -j , i );
115115 }
116116 }
117117
118118 private void epsHalver (int [] array , int [] map , int [] idx , Random r , int a , int m , int h , boolean odd ) {
119- for (int k = HALVER_DEPTH -2 ; k > 0 ; k --) {
120- for (int i = 0 ; i < h ; i ++) {
119+ for (int k = HALVER_DEPTH -2 ; k > 0 ; k --) {
120+ for (int i = 0 ; i < h ; i ++) {
121121 int j = r .nextInt (i +1 );
122122 idx [i ] = idx [j ];
123123 idx [j ] = i ;
124124 Writes .changeAuxWrites (2 );
125125 }
126- for (int i = 0 , s ; i < h ; i ++)
127- if ((s = idx [i ]) < h -1 || !odd )
126+ for (int i = 0 , s ; i < h ; i ++)
127+ if ((s = idx [i ]) < h -1 || !odd )
128128 this .compSwap (array , map , a +i , m +s );
129129 }
130- for (int i = 0 , s ; i < h ; i ++)
131- if ((s = i ) < h -1 || !odd )
130+ for (int i = 0 , s ; i < h ; i ++)
131+ if ((s = i ) < h -1 || !odd )
132132 this .compSwap (array , map , a +i , m +s );
133133
134- for (int i = 0 , s ; i < h ; i ++)
135- if ((s = (i +1 )%h ) < h -1 || !odd )
134+ for (int i = 0 , s ; i < h ; i ++)
135+ if ((s = (i +1 )%h ) < h -1 || !odd )
136136 this .compSwap (array , map , a +i , m +s );
137137 }
138138
139139 private void epsNearsort (int [] array , int [] map , int [] idx , Random r , int a , int n , int d ) {
140- if (n <= MIN_SORT || d >= NEARSORT_DEPTH ) {
141- if (n <= MIN_SORT ) this .smallSort (array , map , a , a +n );
140+ if (n <= MIN_SORT || d >= NEARSORT_DEPTH ) {
141+ if (n <= MIN_SORT ) this .smallSort (array , map , a , a +n );
142142 return ;
143143 }
144144
@@ -160,7 +160,7 @@ private void cherry(int[] array, int[] map, int[] idx, Random rand, int[][] tree
160160
161161 int l = 2 *root + 1 , r = l +1 ;
162162
163- if (l < tSize ) { // if left and right child nodes exist
163+ if (l < tSize ) { // if left and right child nodes exist
164164 j = this .mapInt (map , tree [l ], 0 , j );
165165 j = this .mapInt (map , tree [l ], 1 , j );
166166 j = this .mapInt (map , tree [r ], 0 , j );
@@ -173,28 +173,28 @@ private void cherry(int[] array, int[] map, int[] idx, Random rand, int[][] tree
173173 private void zig (int [] array , int [] map , int [] idx , Random rand , int [][] tree , int t ) {
174174 int tSize = (2 << t ) - 1 ;
175175
176- for (int i = 1 ; i <= tSize ; i = 4 *i + 3 )
177- for (int j = i /2 ; j < i ; j ++)
176+ for (int i = 1 ; i <= tSize ; i = 4 *i + 3 )
177+ for (int j = i /2 ; j < i ; j ++)
178178 this .cherry (array , map , idx , rand , tree , j , tSize );
179179 }
180180 private void zag (int [] array , int [] map , int [] idx , Random rand , int [][] tree , int t ) {
181181 this .epsNearsort (array , map , idx , rand , 0 , mapInt (map , tree [0 ], 1 , mapInt (map , tree [0 ], 0 , 0 )), 0 );
182182
183183 int tSize = (2 << t ) - 1 ;
184184
185- for (int i = 3 ; i <= tSize ; i = 4 *i + 3 )
186- for (int j = i /2 ; j < i ; j ++)
185+ for (int i = 3 ; i <= tSize ; i = 4 *i + 3 )
186+ for (int j = i /2 ; j < i ; j ++)
187187 this .cherry (array , map , idx , rand , tree , j , tSize );
188188 }
189189
190190 @ Override
191191 public void runSort (int [] array , int length , int bucketCount ) {
192192 this .end = length ;
193193
194- if (length <= MIN_SORT ) {
194+ if (length <= MIN_SORT ) {
195195 int [] map = Writes .createExternalArray (length );
196196
197- for (int i = 0 ; i < length ; i ++)
197+ for (int i = 0 ; i < length ; i ++)
198198 Writes .write (map , i , i , 0 , false , true );
199199
200200 this .smallSort (array , map , 0 , length );
@@ -218,9 +218,9 @@ public void runSort(int[] array, int length, int bucketCount) {
218218 boolean minSort = false ;
219219
220220 sortLoop :
221- for (int t = 1 ; t < logN ; t ++) { // O(log n)
222- for (int i = 0 , k = 0 ; i <= t ; i ++) {
223- for (int j = 0 , s = N >> i ; !minSort && j < (1 <<i ); j ++) {
221+ for (int t = 1 ; t < logN ; t ++) { // O(log n)
222+ for (int i = 0 , k = 0 ; i <= t ; i ++) {
223+ for (int j = 0 , s = N >> i ; !minSort && j < (1 <<i ); j ++) {
224224 int p = j * s ,
225225 l1 = p + (j %2 == 1 ? 0 : Y (i ,t )),
226226 l2 = p + Y (i +1 ,t ),
@@ -229,18 +229,18 @@ public void runSort(int[] array, int length, int bucketCount) {
229229
230230 minSort |= (l2 -l1 == 0 && s <= MIN_SORT ); // detects when aks sorts elements
231231 // with a distance <= MIN_SORT
232- if (i == t ) l2 = r1 = r2 ;
232+ if (i == t ) l2 = r1 = r2 ;
233233
234- if (minSort ) {
235- for (k = 0 ; k < s ; k ++) Writes .write (map , k , p +k , 0 , false , true );
234+ if (minSort ) {
235+ for (k = 0 ; k < s ; k ++) Writes .write (map , k , p +k , 0 , false , true );
236236 this .smallSort (array , map , 0 , s );
237237 }
238238 else this .writeInterval (tree , k ++, l1 , l2 , r1 , r2 );
239239 }
240- if (minSort ) break sortLoop ;
240+ if (minSort ) break sortLoop ;
241241 }
242- for (int i = 0 ; i < ZIG_ZAG_ITER ; i ++) {
243- if (i %2 == 1 ) this .zag (array , map , idx , r , tree , t );
242+ for (int i = 0 ; i < ZIG_ZAG_ITER ; i ++) {
243+ if (i %2 == 1 ) this .zag (array , map , idx , r , tree , t );
244244 else this .zig (array , map , idx , r , tree , t );
245245 }
246246 }
0 commit comments