List of usage examples for java.util Arrays copyOf
public static boolean[] copyOf(boolean[] original, int newLength)
From source file:Main.java
public static <T> T[] arrayConcat(T[] first, T[] second) { T[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); return result; }
From source file:Main.java
public static <T> T[] splice(T[] arr, int start, int end) { int size = end - start; T[] newArr = Arrays.copyOf(arr, size); System.arraycopy(arr, start, newArr, 0, size); return newArr; }
From source file:Main.java
public static float[] reverse(float[] array) { float[] result = Arrays.copyOf(array, array.length); for (int i = 0; i < result.length / 2; i++) { float temp = result[i]; result[i] = result[result.length - i - 1]; result[result.length - i - 1] = temp; }// w w w . jav a 2 s . c om return result; }
From source file:Main.java
public static float[] copyArray(float[] array) { return array == null ? null : Arrays.copyOf(array, array.length); }
From source file:Main.java
public static <T> List<T> asConstList(T... in) { return Collections.unmodifiableList(Arrays.asList(Arrays.copyOf(in, in.length))); }
From source file:Main.java
public static byte[] trimmedBytes(byte[] bytes) { int i = bytes.length - 1; while (i >= 0 && bytes[i] == 0) { --i;/*from ww w .j a v a2 s . c o m*/ } return Arrays.copyOf(bytes, i + 1); }
From source file:Main.java
public static String[] contact(String[] strs1, String[] strs2) { if (strs1 == null || strs2 == null) { return null; }/* w ww. j a va2s.com*/ String[] result = Arrays.copyOf(strs1, strs1.length + strs2.length); System.arraycopy(strs2, 0, result, strs1.length, strs2.length); return result; }
From source file:Main.java
public static <T> T[] concat(T[] first, T[] second) { if (first == null && second == null) { return null; } else if (first == null) { return Arrays.copyOf(second, second.length); } else if (second == null) { return Arrays.copyOf(first, first.length); } else {//from w ww.j a v a 2s .c om T[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); return result; } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public static <T> T[] concatenate(T[] first, T[] second) { T[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); return result; }
From source file:Main.java
public static <T> T[] concat(T[] first, T[] second) { if (first == null || second == null) return null; T[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); return result; }