/** Compute the length of the next run, make the run sorted and return its * length. */ int nextRun() { final int runBase = runEnd(0); assert runBase < to; if (runBase == to - 1) { return 1; } int o = runBase + 2; if (compare(runBase, runBase+1) > 0) { // run must be strictly descending while (o < to && compare(o - 1, o) > 0) { ++o; } reverse(runBase, o); } else { // run must be non-descending while (o < to && compare(o - 1, o) <= 0) { ++o; } } final int runHi = Math.max(o, Math.min(to, runBase + minRun)); binarySort(runBase, runHi, o); return runHi - runBase; }
/** Compute the length of the next run, make the run sorted and return its * length. */ int nextRun() { final int runBase = runEnd(0); assert runBase < to; if (runBase == to - 1) { return 1; } int o = runBase + 2; if (compare(runBase, runBase+1) > 0) { // run must be strictly descending while (o < to && compare(o - 1, o) > 0) { ++o; } reverse(runBase, o); } else { // run must be non-descending while (o < to && compare(o - 1, o) <= 0) { ++o; } } final int runHi = Math.max(o, Math.min(to, runBase + minRun)); binarySort(runBase, runHi, o); return runHi - runBase; }
/** Compute the length of the next run, make the run sorted and return its * length. */ int nextRun() { final int runBase = runEnd(0); assert runBase < to; if (runBase == to - 1) { return 1; } int o = runBase + 2; if (compare(runBase, runBase+1) > 0) { // run must be strictly descending while (o < to && compare(o - 1, o) > 0) { ++o; } reverse(runBase, o); } else { // run must be non-descending while (o < to && compare(o - 1, o) <= 0) { ++o; } } final int runHi = Math.max(o, Math.min(to, runBase + minRun)); binarySort(runBase, runHi, o); return runHi - runBase; }
/** Compute the length of the next run, make the run sorted and return its * length. */ int nextRun() { final int runBase = runEnd(0); assert runBase < to; if (runBase == to - 1) { return 1; } int o = runBase + 2; if (compare(runBase, runBase+1) > 0) { // run must be strictly descending while (o < to && compare(o - 1, o) > 0) { ++o; } reverse(runBase, o); } else { // run must be non-descending while (o < to && compare(o - 1, o) <= 0) { ++o; } } final int runHi = Math.max(o, Math.min(to, runBase + minRun)); binarySort(runBase, runHi, o); return runHi - runBase; }