Arrays { @Beta public static void fill(final byte[] array, final int startIdx, final int endIdx, final byte value) { int len = endIdx - startIdx; if (len > 0) { if (endIdx > array.length || startIdx < 0) { throw new IllegalArgumentException("Illegal range from " + startIdx + " to " + endIdx); } if (len <= ARR_CPY_THR) { for (int i = startIdx; i < endIdx; i++) { array[i] = value; } } else { int fillEnd = startIdx + ARR_CPY_THR; for (int i = startIdx; i < fillEnd; i++) { array[i] = value; } array[startIdx] = value; for (int i = ARR_CPY_THR; i < len; i += i) { int lmi = len - i; int from = startIdx + i; if (lmi < i) { if (lmi < ARR_CPY_THR) { int xe = from + lmi; for (int j = from; j < xe; j++) { array[j] = value; } } else { System.arraycopy(array, startIdx, array, from, lmi); } } else { System.arraycopy(array, startIdx, array, from, i); } } } } else if (len < 0) { throw new IllegalArgumentException("Illegal range from " + startIdx + " to " + endIdx); } } private  Arrays(); static double[] getColumnAsDoubles(final long[][] data, final int columnNumber); static double[] getColumn(final double[][] data, final int columnNumber); static double[] toDoubleArray(final long... larr); static Object[] toObjectArray(final long... larr); static double[] divide(final double[] arr1, final double[] arr2); static boolean deepEquals(final Object[] a1, final Object[] a2, final int starting); static boolean deepEquals(final Object[] a1, final Object[] a2, final int starting, final int ending); static boolean equals(final byte[] a, final byte[] b, final int a1,  final int b1, final int length); static int search(final char[] array, final char c); static T[] moveOfRange(final T[] original, final int from, final int to); static T[] append(final T[] array, final T value); @GwtIncompatible static T[] preppend(final T[] array, final T value); @GwtIncompatible static T[] preppend(final T[] array, final T... values); static T[] append(final T[] array, final T... values); static T[] concat(final T[]... arrays); static byte[] concat(final  byte[]... arrays); static int indexOf(final T[] array, final T content); @Beta static void fill(final byte[] array, final int startIdx, final int endIdx, final byte value); @Beta static void fill(final T[] array, final int startIdx, final int endIdx, final T value); @Beta static void fill(final char[] array, final int startIdx, final int endIdx, final char value); @Beta static void fill(final int[] array, final int startIdx, final int endIdx, final int value); @Beta static void fill(final long[] array, final int startIdx, final int endIdx, final long value); @Beta static void fill(final double[] array, final int startIdx, final int endIdx, final double value); static final Object[] EMPTY_OBJ_ARRAY; static final Annotation[] EMPTY_ANNOT_ARRAY; static final Class[] EMPTY_CLASS_ARRAY; static final String[] EMPTY_STRING_ARRAY; static final byte[] EMPTY_BYTE_ARRAY; static final boolean[] EMPTY_BOOLEAN_ARRAY; static final long[] EMPTY_LONG_ARRAY; static final int[] EMPTY_INT_ARRAY; }
@Test public void testFill() { String[] testArray = new String[64]; java.util.Arrays.fill(testArray, "a"); String[] a1 = testArray.clone(); String[] a2 = testArray.clone(); java.util.Arrays.fill(a1, 50, 64, null); Arrays.fill(a2, 50, 64, null); Assert.assertArrayEquals(a1, a2); }
@Test public void testFill2() { String[] testArray = new String[1024]; java.util.Arrays.fill(testArray, "a"); String[] a1 = testArray.clone(); String[] a2 = testArray.clone(); java.util.Arrays.fill(a1, 50, 800, null); Arrays.fill(a2, 50, 800, null); Assert.assertArrayEquals(a1, a2); }
@Test public void testFill3() { String[] testArray = new String[64]; java.util.Arrays.fill(testArray, "a"); String[] a1 = testArray.clone(); String[] a2 = testArray.clone(); java.util.Arrays.fill(a1, 50, 51, null); Arrays.fill(a2, 50, 51, null); Assert.assertArrayEquals(a1, a2); }
@Test(expected = IllegalArgumentException.class) public void testFill4() { String[] testArray = new String[64]; Arrays.fill(testArray, 50, 49, null); }