qsort(a, fromIndex, toIndex);
}
- private static short cmp(byte i, byte j)
- {
- return (short) (i - j);
- }
-
private static int med3(int a, int b, int c, byte[]d)
{
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
+ return d[a] < d[b] ?
+ (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+ : (d[b] > d[c] ? b : d[a] > d[c] ? c : a);
}
private static void swap(int i, int j, byte[]a)
private static void qsort(byte[]a, int start, int n)
{
// use an insertion sort on small arrays
- if (n < 7)
+ if (n <= 7)
{
for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j - 1], a[j]) > 0; j--)
+ for (int j = i; j > 0 && a[j - 1] > a[j]; j--)
swap(j, j - 1, a);
return;
}
}
int pa, pb, pc, pd, pv;
- short r;
+ int r;
pv = start;
swap(pv, pm, a);
for (;;)
{
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0)
+ while (pb <= pc && (r = a[pb] - a[pv]) <= 0)
{
if (r == 0)
{
}
pb++;
}
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0)
+ while (pc >= pb && (r = a[pc] - a[pv]) >= 0)
{
if (r == 0)
{
qsort(a, fromIndex, toIndex);
}
- private static int cmp(char i, char j)
- {
- return i - j;
- }
-
private static int med3(int a, int b, int c, char[]d)
{
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
+ return d[a] < d[b] ?
+ (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+ : (d[b] > d[c] ? b : d[a] > d[c] ? c : a);
}
private static void swap(int i, int j, char[]a)
private static void qsort(char[]a, int start, int n)
{
// use an insertion sort on small arrays
- if (n < 7)
+ if (n <= 7)
{
for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j - 1], a[j]) > 0; j--)
+ for (int j = i; j > 0 && a[j - 1] > a[j]; j--)
swap(j, j - 1, a);
return;
}
for (;;)
{
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0)
+ while (pb <= pc && (r = a[pb] - a[pv]) <= 0)
{
if (r == 0)
{
}
pb++;
}
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0)
+ while (pc >= pb && (r = a[pc] - a[pv]) >= 0)
{
if (r == 0)
{
qsort(a, fromIndex, toIndex);
}
- private static double cmp(double i, double j)
- {
- return i - j;
- }
-
private static int med3(int a, int b, int c, double[]d)
{
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
+ return d[a] < d[b] ?
+ (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+ : (d[b] > d[c] ? b : d[a] > d[c] ? c : a);
}
private static void swap(int i, int j, double[]a)
private static void qsort(double[]a, int start, int n)
{
// use an insertion sort on small arrays
- if (n < 7)
+ if (n <= 7)
{
for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j - 1], a[j]) > 0; j--)
+ for (int j = i; j > 0 && a[j - 1] > a[j]; j--)
swap(j, j - 1, a);
return;
}
for (;;)
{
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0)
+ while (pb <= pc && (r = a[pb] - a[pv]) <= 0)
{
if (r == 0)
{
}
pb++;
}
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0)
+ while (pc >= pb && (r = a[pc] - a[pv]) >= 0)
{
if (r == 0)
{
qsort(a, fromIndex, toIndex);
}
- private static float cmp(float i, float j)
- {
- return i - j;
- }
-
private static int med3(int a, int b, int c, float[]d)
{
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
+ return d[a] < d[b] ?
+ (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+ : (d[b] > d[c] ? b : d[a] > d[c] ? c : a);
}
private static void swap(int i, int j, float[]a)
private static void qsort(float[]a, int start, int n)
{
// use an insertion sort on small arrays
- if (n < 7)
+ if (n <= 7)
{
for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j - 1], a[j]) > 0; j--)
+ for (int j = i; j > 0 && a[j - 1] > a[j]; j--)
swap(j, j - 1, a);
return;
}
for (;;)
{
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0)
+ while (pb <= pc && (r = a[pb] - a[pv]) <= 0)
{
if (r == 0)
{
}
pb++;
}
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0)
+ while (pc >= pb && (r = a[pc] - a[pv]) >= 0)
{
if (r == 0)
{
qsort(a, fromIndex, toIndex);
}
- private static long cmp(int i, int j)
- {
- return (long) i - (long) j;
- }
-
private static int med3(int a, int b, int c, int[]d)
{
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
+ return d[a] < d[b] ?
+ (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+ : (d[b] > d[c] ? b : d[a] > d[c] ? c : a);
}
private static void swap(int i, int j, int[]a)
private static void qsort(int[]a, int start, int n)
{
// use an insertion sort on small arrays
- if (n < 7)
+ if (n <= 7)
{
for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j - 1], a[j]) > 0; j--)
+ for (int j = i; j > 0 && a[j - 1] > a[j]; j--)
swap(j, j - 1, a);
return;
}
}
int pa, pb, pc, pd, pv;
- long r;
+ int r;
pv = start;
swap(pv, pm, a);
for (;;)
{
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0)
+ while (pb <= pc && (r = a[pb] - a[pv]) <= 0)
{
if (r == 0)
{
}
pb++;
}
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0)
+ while (pc >= pb && (r = a[pc] - a[pv]) >= 0)
{
if (r == 0)
{
qsort(a, fromIndex, toIndex);
}
- // The "cmp" method has been removed from here and replaced with direct
- // compares in situ, to avoid problems with overflow if the difference
- // between two numbers is bigger than a long will hold.
- // One particular change as a result is the use of r1 and r2 in qsort
-
private static int med3(int a, int b, int c, long[]d)
{
- return d[a] < d[b] ?
- (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
- : (d[b] > d[c] ? b : d[a] > d[c] ? c : a);
+ return d[a] < d[b] ?
+ (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+ : (d[b] > d[c] ? b : d[a] > d[c] ? c : a);
}
private static void swap(int i, int j, long[]a)
private static void qsort(long[]a, int start, int n)
{
// use an insertion sort on small arrays
- if (n < 7)
+ if (n <= 7)
{
for (int i = start + 1; i < start + n; i++)
for (int j = i; j > 0 && a[j - 1] > a[j]; j--)
}
int pa, pb, pc, pd, pv;
- long r1, r2;
+ long r;
pv = start;
swap(pv, pm, a);
for (;;)
{
- while (pb <= pc && (r1 = a[pb]) <= (r2 = a[pv]))
+ while (pb <= pc && (r = a[pb] - a[pv]) <= 0)
{
- if (r1 == r2)
+ if (r == 0)
{
swap(pa, pb, a);
pa++;
}
pb++;
}
- while (pc >= pb && (r1 = a[pc]) >= (r2 = a[pv]))
+ while (pc >= pb && (r = a[pc] - a[pv]) >= 0)
{
- if (r1 == r2)
+ if (r == 0)
{
swap(pc, pd, a);
pd--;
qsort(a, fromIndex, toIndex);
}
- private static int cmp(short i, short j)
- {
- return i - j;
- }
-
private static int med3(int a, int b, int c, short[]d)
{
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
+ return d[a] < d[b] ?
+ (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+ : (d[b] > d[c] ? b : d[a] > d[c] ? c : a);
}
private static void swap(int i, int j, short[]a)
private static void qsort(short[]a, int start, int n)
{
// use an insertion sort on small arrays
- if (n < 7)
+ if (n <= 7)
{
for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j - 1], a[j]) > 0; j--)
+ for (int j = i; j > 0 && a[j - 1] > a[j]; j--)
swap(j, j - 1, a);
return;
}
for (;;)
{
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0)
+ while (pb <= pc && (r = a[pb] - a[pv]) <= 0)
{
if (r == 0)
{
}
pb++;
}
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0)
+ while (pc >= pb && (r = a[pc] - a[pv]) >= 0)
{
if (r == 0)
{