if (count > 40)
{ // big arrays, pseudomedian of 9
int s = count / 8;
- lo = med3(lo, lo + s, lo + s + s, array);
+ lo = med3(lo, lo + s, lo + 2 * s, array);
mid = med3(mid - s, mid, mid + s, array);
- hi = med3(hi - s - s, hi - s, hi, array);
+ hi = med3(hi - 2 * s, hi - s, hi, array);
}
mid = med3(lo, mid, hi, array);
// Pull the median element out of the fray, and use it as a pivot.
swap(from, mid, array);
- a = b = from + 1;
- c = d = hi;
+ a = b = from;
+ c = d = from + count - 1;
// Repeatedly move b and c to each other, swapping elements so
// that all elements before index b are less than the pivot, and all
}
// Swap pivot(s) back in place, the recurse on left and right sections.
+ hi = from + count;
int span;
span = Math.min(a - from, b - a);
vecswap(from, b - span, span, array);
span = Math.min(d - c, hi - d - 1);
- vecswap(b, hi - span + 1, span, array);
+ vecswap(b, hi - span, span, array);
span = b - a;
if (span > 1)
span = d - c;
if (span > 1)
- qsort(array, hi - span + 1, span);
+ qsort(array, hi - span, span);
}
/**
if (count > 40)
{ // big arrays, pseudomedian of 9
int s = count / 8;
- lo = med3(lo, lo + s, lo + s + s, array);
+ lo = med3(lo, lo + s, lo + 2 * s, array);
mid = med3(mid - s, mid, mid + s, array);
- hi = med3(hi - s - s, hi - s, hi, array);
+ hi = med3(hi - 2 * s, hi - s, hi, array);
}
mid = med3(lo, mid, hi, array);
// Pull the median element out of the fray, and use it as a pivot.
swap(from, mid, array);
- a = b = from + 1;
- c = d = hi;
+ a = b = from;
+ c = d = from + count - 1;
// Repeatedly move b and c to each other, swapping elements so
// that all elements before index b are less than the pivot, and all
}
// Swap pivot(s) back in place, the recurse on left and right sections.
+ hi = from + count;
int span;
span = Math.min(a - from, b - a);
vecswap(from, b - span, span, array);
span = Math.min(d - c, hi - d - 1);
- vecswap(b, hi - span + 1, span, array);
+ vecswap(b, hi - span, span, array);
span = b - a;
if (span > 1)
span = d - c;
if (span > 1)
- qsort(array, hi - span + 1, span);
+ qsort(array, hi - span, span);
}
/**
if (count > 40)
{ // big arrays, pseudomedian of 9
int s = count / 8;
- lo = med3(lo, lo + s, lo + s + s, array);
+ lo = med3(lo, lo + s, lo + 2 * s, array);
mid = med3(mid - s, mid, mid + s, array);
- hi = med3(hi - s - s, hi - s, hi, array);
+ hi = med3(hi - 2 * s, hi - s, hi, array);
}
mid = med3(lo, mid, hi, array);
// Pull the median element out of the fray, and use it as a pivot.
swap(from, mid, array);
- a = b = from + 1;
- c = d = hi;
+ a = b = from;
+ c = d = from + count - 1;
// Repeatedly move b and c to each other, swapping elements so
// that all elements before index b are less than the pivot, and all
}
// Swap pivot(s) back in place, the recurse on left and right sections.
+ hi = from + count;
int span;
span = Math.min(a - from, b - a);
vecswap(from, b - span, span, array);
span = Math.min(d - c, hi - d - 1);
- vecswap(b, hi - span + 1, span, array);
+ vecswap(b, hi - span, span, array);
span = b - a;
if (span > 1)
span = d - c;
if (span > 1)
- qsort(array, hi - span + 1, span);
+ qsort(array, hi - span, span);
}
/**
if (count > 40)
{ // big arrays, pseudomedian of 9
int s = count / 8;
- lo = med3(lo, lo + s, lo + s + s, array);
+ lo = med3(lo, lo + s, lo + 2 * s, array);
mid = med3(mid - s, mid, mid + s, array);
- hi = med3(hi - s - s, hi - s, hi, array);
+ hi = med3(hi - 2 * s, hi - s, hi, array);
}
mid = med3(lo, mid, hi, array);
// Pull the median element out of the fray, and use it as a pivot.
swap(from, mid, array);
- a = b = from + 1;
- c = d = hi;
+ a = b = from;
+ c = d = from + count - 1;
// Repeatedly move b and c to each other, swapping elements so
// that all elements before index b are less than the pivot, and all
}
// Swap pivot(s) back in place, the recurse on left and right sections.
+ hi = from + count;
int span;
span = Math.min(a - from, b - a);
vecswap(from, b - span, span, array);
span = Math.min(d - c, hi - d - 1);
- vecswap(b, hi - span + 1, span, array);
+ vecswap(b, hi - span, span, array);
span = b - a;
if (span > 1)
span = d - c;
if (span > 1)
- qsort(array, hi - span + 1, span);
+ qsort(array, hi - span, span);
}
/**
if (count > 40)
{ // big arrays, pseudomedian of 9
int s = count / 8;
- lo = med3(lo, lo + s, lo + s + s, array);
+ lo = med3(lo, lo + s, lo + 2 * s, array);
mid = med3(mid - s, mid, mid + s, array);
- hi = med3(hi - s - s, hi - s, hi, array);
+ hi = med3(hi - 2 * s, hi - s, hi, array);
}
mid = med3(lo, mid, hi, array);
// Pull the median element out of the fray, and use it as a pivot.
swap(from, mid, array);
- a = b = from + 1;
- c = d = hi;
+ a = b = from;
+ c = d = from + count - 1;
// Repeatedly move b and c to each other, swapping elements so
// that all elements before index b are less than the pivot, and all
}
// Swap pivot(s) back in place, the recurse on left and right sections.
+ hi = from + count;
int span;
span = Math.min(a - from, b - a);
vecswap(from, b - span, span, array);
span = Math.min(d - c, hi - d - 1);
- vecswap(b, hi - span + 1, span, array);
+ vecswap(b, hi - span, span, array);
span = b - a;
if (span > 1)
span = d - c;
if (span > 1)
- qsort(array, hi - span + 1, span);
+ qsort(array, hi - span, span);
}
/**
if (count > 40)
{ // big arrays, pseudomedian of 9
int s = count / 8;
- lo = med3(lo, lo + s, lo + s + s, array);
+ lo = med3(lo, lo + s, lo + 2 * s, array);
mid = med3(mid - s, mid, mid + s, array);
- hi = med3(hi - s - s, hi - s, hi, array);
+ hi = med3(hi - 2 * s, hi - s, hi, array);
}
mid = med3(lo, mid, hi, array);
// Pull the median element out of the fray, and use it as a pivot.
swap(from, mid, array);
- a = b = from + 1;
- c = d = hi;
+ a = b = from;
+ c = d = from + count - 1;
// Repeatedly move b and c to each other, swapping elements so
// that all elements before index b are less than the pivot, and all
}
// Swap pivot(s) back in place, the recurse on left and right sections.
+ hi = from + count;
int span;
span = Math.min(a - from, b - a);
vecswap(from, b - span, span, array);
span = Math.min(d - c, hi - d - 1);
- vecswap(b, hi - span + 1, span, array);
+ vecswap(b, hi - span, span, array);
span = b - a;
if (span > 1)
span = d - c;
if (span > 1)
- qsort(array, hi - span + 1, span);
+ qsort(array, hi - span, span);
}
/**
if (count > 40)
{ // big arrays, pseudomedian of 9
int s = count / 8;
- lo = med3(lo, lo + s, lo + s + s, array);
+ lo = med3(lo, lo + s, lo + 2 * s, array);
mid = med3(mid - s, mid, mid + s, array);
- hi = med3(hi - s - s, hi - s, hi, array);
+ hi = med3(hi - 2 * s, hi - s, hi, array);
}
mid = med3(lo, mid, hi, array);
// Pull the median element out of the fray, and use it as a pivot.
swap(from, mid, array);
- a = b = from + 1;
- c = d = hi;
+ a = b = from;
+ c = d = from + count - 1;
// Repeatedly move b and c to each other, swapping elements so
// that all elements before index b are less than the pivot, and all
}
// Swap pivot(s) back in place, the recurse on left and right sections.
+ hi = from + count;
int span;
span = Math.min(a - from, b - a);
vecswap(from, b - span, span, array);
span = Math.min(d - c, hi - d - 1);
- vecswap(b, hi - span + 1, span, array);
+ vecswap(b, hi - span, span, array);
span = b - a;
if (span > 1)
span = d - c;
if (span > 1)
- qsort(array, hi - span + 1, span);
+ qsort(array, hi - span, span);
}
/**