List of utility methods to do Array Concatenate
T[] | concat(T[] first, T[]... rest) concat int totalLength = first.length; for (T[] arr : rest) { totalLength += arr.length; T[] result = (T[]) Array.newInstance(first.getClass(), totalLength); System.arraycopy(first, 0, result, 0, first.length); int pos = first.length; for (T[] arr : rest) { ... |
byte[] | concat(byte[] first, byte[]... rest) concat int totalLength = first.length; for (byte[] arr : rest) { totalLength += arr.length; byte[] result = new byte[totalLength]; System.arraycopy(first, 0, result, 0, first.length); int pos = first.length; for (byte[] arr : rest) { ... |
byte[] | cancat(byte[] a, byte[] b) cancat int alen = a.length; int blen = b.length; byte[] result = new byte[alen + blen]; System.arraycopy(a, 0, result, 0, alen); System.arraycopy(b, 0, result, alen, blen); return result; |
byte[] | arrayApend(byte[] prep, byte after) array Apend byte[] result = new byte[prep.length + 1]; System.arraycopy(prep, 0, result, 0, prep.length); result[prep.length] = after; return result; |
byte[] | arrayComb(byte[] prep, byte[] after) array Comb byte[] result = new byte[prep.length + after.length]; System.arraycopy(prep, 0, result, 0, prep.length); System.arraycopy(after, 0, result, prep.length, after.length); return result; |
T[] | concat(T[] a, T[] b) concat final int alen = a.length; final int blen = b.length; if (alen == 0) { return b; if (blen == 0) { return a; final T[] result = (T[]) Array.newInstance(a.getClass() .getComponentType(), alen + blen); System.arraycopy(a, 0, result, 0, alen); System.arraycopy(b, 0, result, alen, blen); return result; |
T[] | concatAll(T[] first, T[]... rest) concat All int totalLength = first.length; for (T[] array : rest) { totalLength += array.length; T[] result = Arrays.copyOf(first, totalLength); int offset = first.length; for (T[] array : rest) { System.arraycopy(array, 0, result, offset, array.length); ... |
byte[] | concatenate(byte[]... bytes) concatenate int length = 0; for (byte[] array : bytes) length += array.length; byte[] result = new byte[length]; int offset = 0; for (byte[] array : bytes) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; ... |
T[] | concat(T[] first, T[] second) concat T[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;
|
byte[] | concat(byte[] b1, byte[] b2) concat byte[] ret = new byte[b1.length + b2.length]; System.arraycopy(b1, 0, ret, 0, b1.length); System.arraycopy(b2, 0, ret, b1.length, b2.length); return ret; |