Arrays2 { public static void shift(double[] array, int shiftsize) { shift(array, shiftsize, 0, array.length); } private  Arrays2(); static void copy(final double[] sourceArray,
            final double[] destinationArray, final int length); static void reverse(final double[] array); static void reverse(final double[] array, final int start, final int n); static void reverse(final int[] array); static void reverse(final int[] array, final int start, final int n); static void reverse(final Object[] array); static void reverse(final Object[] array, final int start, final int n); static void swap(double array[], int a, int b); static void swap(int array[], int a, int b); static void swap(Object array[], int a, int b); static boolean isNullOrEmpty(Object[] array); static boolean isNullOrEmpty(double[] array); static boolean isNullOrEmpty(int[] array); static T[] copyOf(T[] original); static T[] concat(T[] first, T[] second); static double[] concat(double[]... arrays); static double[] compact(final double[] array); static void shift(double[] array, int shiftsize); static void shift(double[] array, int shiftsize, int fromIndex, int toIndex); static boolean isArray(Object o); static boolean arrayEquals(T oldValue, T newValue); static List<T> unmodifiableList(T... array); static final String[] EMPTY_STRING_ARRAY; static final int[] EMPTY_INT_ARRAY; static final long[] EMPTY_LONG_ARRAY; static final double[] EMPTY_DOUBLE_ARRAY; static final boolean[] EMPTY_BOOLEAN_ARRAY; }
@Test public void testShift() { double[] t1 = {1, 2, 3, 4, 5}; double[] r1 = {1, 1, 2, 3, 4}; Arrays2.shift(t1, 1); assertArrayEquals(r1, t1, NO_DELTA); double[] t2 = {1, 2, 3, 4, 5}; double[] r2 = {1, 2, 1, 2, 3}; Arrays2.shift(t2, 2); assertArrayEquals(r2, t2, NO_DELTA); double[] t3 = {1, 2, 3, 4, 5}; double[] r3 = {2, 3, 4, 5, 5}; Arrays2.shift(t3, -1); assertArrayEquals(r3, t3, NO_DELTA); double[] t4 = {1, 2, 3, 4, 5}; double[] r4 = {3, 4, 5, 4, 5}; Arrays2.shift(t4, -2); assertArrayEquals(r4, t4, NO_DELTA); double[] t5 = {1, 2, 3, 4, 5}; double[] r5 = {1, 2, 3, 4, 5}; Arrays2.shift(t5, 0); assertArrayEquals(r5, t5, NO_DELTA); }
@Test public void testShiftRange() { double[] t1 = {99, 88, 1, 2, 3, 4, 5, 77, 66}; double[] r1 = {99, 88, 1, 1, 2, 3, 4, 77, 66}; Arrays2.shift(t1, 1, 2, 7); assertArrayEquals(r1, t1, NO_DELTA); double[] t2 = {99, 88, 1, 2, 3, 4, 5, 77, 66}; double[] r2 = {99, 88, 1, 2, 1, 2, 3, 77, 66}; Arrays2.shift(t2, 2, 2, 7); assertArrayEquals(r2, t2, NO_DELTA); double[] t3 = {99, 88, 1, 2, 3, 4, 5, 77, 66}; double[] r3 = {99, 88, 2, 3, 4, 5, 5, 77, 66}; Arrays2.shift(t3, -1, 2, 7); assertArrayEquals(r3, t3, NO_DELTA); double[] t4 = {99, 88, 1, 2, 3, 4, 5, 77, 66}; double[] r4 = {99, 88, 3, 4, 5, 4, 5, 77, 66}; Arrays2.shift(t4, -2, 2, 7); assertArrayEquals(r4, t4, NO_DELTA); double[] t5 = {99, 88, 1, 2, 3, 4, 5, 77, 66}; double[] r5 = {99, 88, 1, 2, 3, 4, 5, 77, 66}; Arrays2.shift(t5, 0, 2, 7); assertArrayEquals(r5, t5, NO_DELTA); double[] t6 = {1, 2, 3, 4}; double[] r6 = {1, 1, 2, 3}; Arrays2.shift(t6, 1, 0, t6.length); assertArrayEquals(r6, t6, NO_DELTA); }