List of utility methods to do Array Merge
List | merge(T[]... many) merge ArrayList<T> ret = new ArrayList(); for (T[] list : many) { if (list != null) { for (T val : list) { if (!ret.contains(val)) { ret.add(val); ret.trimToSize(); return ret; |
String[] | merge2TablesWithoutDup(String[] t1, String[] t2) Source https://stackoverflow.com/questions/16520046/how-to-merge-two-arraylists-without-duplicates Added by JG 2017 List<String> sL1 = new ArrayList<String>(Arrays.asList(t1)); for (int i = 0; i < t2.length; i++) { if (!sL1.contains(t2[i])) sL1.add(t2[i]); String[] f = sL1.toArray(new String[0]); return f; |
int[] | mergeAndOrderArray(int[] arrA, int[] arrB) merge And Order Array int[] arr = new int[arrA.length + arrB.length]; int a = 0; int b = 0; for (int i = 0; i < arr.length; i++) { if (a == arrA.length) { arr[i] = arrB[b]; b++; } else if (b == arrB.length) { ... |
String[] | mergeArgs(String[] args) merge Args ArrayList<String> merged = new ArrayList<>(); boolean open = false; StringBuilder builder = new StringBuilder(); for (String arg : args) { if (open) { if (builder.length() != 0) { builder.append(' '); if (arg.endsWith("\"")) { open = false; builder.append(arg.substring(0, arg.length() - 1)); merged.add(builder.toString()); builder = new StringBuilder(); } else { builder.append(arg); } else if (arg.startsWith("\"")) { open = true; builder.append(arg.substring(1)); } else { merged.add(arg); if (builder.length() != 0) { merged.add(builder.toString()); return merged.toArray(new String[merged.size()]); |
byte[] | mergeArray(byte[] arr1, byte[] arr2) merge Array byte[] result = new byte[arr1.length + arr2.length]; for (int i = 0; i < arr1.length; i++) result[i] = arr1[i]; for (int i = 0; i < arr2.length; i++) result[i + arr1.length] = arr2[i]; return result; |
void | mergeArray(final Object[] dest, final Object[]... arrays) merge Array if (arrays == null || arrays.length == 0) return; if (arrays.length == 1) { final Object[] array = arrays[0]; System.arraycopy(array, 0, dest, 0, array.length); return; for (int i = 0, j = arrays.length - 1; i < j; i++) { ... |
String[] | mergeArray(String[] a, String[] b) merge Array if (a == null) { return b; if (b == null) { return a; String[] newArray = new String[a.length + b.length]; System.arraycopy(a, 0, newArray, 0, a.length); ... |
String | mergeArray(T[] objs, String concatenator) merge Array StringBuilder sb = new StringBuilder(); for (T obj : objs) { sb.append(obj).append(concatenator); return objs.length == 0 ? "" : sb.substring(0, sb.length() - concatenator.length()); |
String | mergeArrayIntoString(final Object[] array, String middleDelimiter, String lastDelimiter) merge Array Into String if (array == null) { return null; if (middleDelimiter == null) { middleDelimiter = ""; if (lastDelimiter == null) { lastDelimiter = middleDelimiter; ... |
Object[] | mergeArrayObject(Object[] buf1, Object[] buf2) merge Array Object Object[] bufret = null; int len1 = 0; int len2 = 0; if (buf1 != null) len1 = buf1.length; if (buf2 != null) len2 = buf2.length; if (len1 + len2 > 0) ... |