List of utility methods to do Array Merge
String[] | mergeArrays(String[] array, String[] newEntries) Returns the union of the two arrays specified. ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < array.length; i++) list.add(array[i]); for (int i = 0; i < newEntries.length; i++) if (!list.contains(newEntries[i])) list.add(newEntries[i]); String[] newArray = new String[list.size()]; return list.toArray(newArray); ... |
String[] | mergeArrays(String[] data1, String[] data2) Merge 2 string's arrays data1 and data2 to one array of string 'data1 + data2'. if (data1 == null && data2 == null) { return null; if (data1 == null) { return data2; if (data2 == null) { return data1; ... |
String[] | mergeArrays(String[] inputArray1, String[] inputArray2) This method merges 2 input string arrays and returns the merged array as output String[] outputArray = new String[inputArray1.length + inputArray2.length]; for (int i = 0; i < inputArray1.length; i++) { outputArray[i] = inputArray1[i]; int outputArrayLength = inputArray1.length; for (int i = 0; i < inputArray2.length; i++) { outputArray[i + outputArrayLength] = inputArray2[i]; return outputArray; |
void | mergeArrays(T[] items, T[]... added) add all added arrays to items int index = 0; for (int i = 0; i < added.length; i++) { T[] item = added[i]; System.arraycopy(item, 0, items, index, item.length); index += item.length; |
T[] | mergeArrays(T[] lhs, T[] rhs) merge Arrays T[] newArray = Arrays.copyOf(lhs, lhs.length + rhs.length); for (int i = lhs.length; i < rhs.length; ++i) { newArray[i] = rhs[i - lhs.length]; return newArray; |
T[] | MergeArrays(T[]... arrs) Merge Arrays ArrayList<T> list = new ArrayList<T>(); for (T[] arr : arrs) { for (T t : arr) { list.add(t); list.trimToSize(); return list.toArray(arrs[0]); ... |
String | mergeArrayToString(final String[] array) merge Array To String if (array == null) return null; final StringBuilder builder = new StringBuilder(); for (final String c : array) { builder.append(c); return builder.toString(); |
int[] | mergeByArray(int[] a, int[] b) merge By Array int[] c = new int[a.length + b.length]; int i = 0, j = 0, k = 0; while (i < a.length && j < b.length) { if (a[i] <= b[j]) { if (a[i] == b[j]) { j++; } else { c[k] = a[i]; ... |
byte[] | mergeByteArraies(byte[] array1, byte[] array2) Merge byte arraies. if (array1 == null) { return array2; } else if (array2 == null) { return array1; } else { byte[] result = new byte[array1.length + array2.length]; System.arraycopy(array1, 0, result, 0, array1.length); System.arraycopy(array2, 0, result, array1.length, array2.length); ... |
byte[] | mergeByteArrays(byte[] array1, byte[] array2) Merges two byte arrays byte[] combined = new byte[array1.length + array2.length]; for (int i = 0; i < combined.length; ++i) { combined[i] = i < array1.length ? array1[i] : array2[i - array1.length]; return combined; |