/** * Rotate a range in place: <code>array[middle]</code> is put in * <code>array[first]</code>, <code>array[middle+1]</code> is put in * <code>array[first+1]</code>, etc. Generally, the element in position * <code>i</code> is put into position * <code>(i + (last-middle)) % (last-first)</code>. * @param array Array containing the range * @param first Beginning of the range * @param middle Index of the element that will be put in * <code>array[first]</code> * @param last One past the end of the range */ private static void rotate(int first, int middle, int last, Swapper swapper) { // no more needed since manually inlined if (middle != first && middle != last) { reverse(first, middle, swapper); reverse(middle, last, swapper); reverse(first, last, swapper); } } /**
/** * Rotate a range in place: <code>array[middle]</code> is put in * <code>array[first]</code>, <code>array[middle+1]</code> is put in * <code>array[first+1]</code>, etc. Generally, the element in position * <code>i</code> is put into position * <code>(i + (last-middle)) % (last-first)</code>. * @param array Array containing the range * @param first Beginning of the range * @param middle Index of the element that will be put in * <code>array[first]</code> * @param last One past the end of the range */ private static void rotate(int first, int middle, int last, Swapper swapper) { // no more needed since manually inlined if (middle != first && middle != last) { reverse(first, middle, swapper); reverse(middle, last, swapper); reverse(first, last, swapper); } } /**
/** * Rotate a range in place: <code>array[middle]</code> is put in * <code>array[first]</code>, <code>array[middle+1]</code> is put in * <code>array[first+1]</code>, etc. Generally, the element in position * <code>i</code> is put into position * <code>(i + (last-middle)) % (last-first)</code>. * * @param array * Array containing the range * @param first * Beginning of the range * @param middle * Index of the element that will be put in * <code>array[first]</code> * @param last * One past the end of the range */ private static void rotate(int first, int middle, int last, Swapper swapper) { // no more needed since manually inlined if (middle != first && middle != last) { reverse(first, middle, swapper); reverse(middle, last, swapper); reverse(first, last, swapper); } }
/** * Rotate a range in place: <code>array[middle]</code> is put in * <code>array[first]</code>, <code>array[middle+1]</code> is put in * <code>array[first+1]</code>, etc. Generally, the element in position * <code>i</code> is put into position * <code>(i + (last-middle)) % (last-first)</code>. * * @param array * Array containing the range * @param first * Beginning of the range * @param middle * Index of the element that will be put in * <code>array[first]</code> * @param last * One past the end of the range */ private static void rotate(int first, int middle, int last, Swapper swapper) { // no more needed since manually inlined if (middle != first && middle != last) { reverse(first, middle, swapper); reverse(middle, last, swapper); reverse(first, last, swapper); } }
/** * Rotate a range in place: <code>array[middle]</code> is put in * <code>array[first]</code>, <code>array[middle+1]</code> is put in * <code>array[first+1]</code>, etc. Generally, the element in position * <code>i</code> is put into position * <code>(i + (last-middle)) % (last-first)</code>. * * @param array * Array containing the range * @param first * Beginning of the range * @param middle * Index of the element that will be put in * <code>array[first]</code> * @param last * One past the end of the range */ private static void rotate(int first, int middle, int last, Swapper swapper) { // no more needed since manually inlined if (middle != first && middle != last) { reverse(first, middle, swapper); reverse(middle, last, swapper); reverse(first, last, swapper); } }