Java Utililty Methods Array Merge

List of utility methods to do Array Merge

Description

The list of methods to do Array Merge are organized into topic(s).

Method

int[]merge(int[] a, int[] b)
merge
int[] c = new int[a.length + b.length];
int p = 0, q = 0;
while (p < a.length && q < b.length) {
    if (a[p] < b[q])
        c[p + q] = a[p++];
    else
        c[p + q] = b[q++];
while (p < a.length)
    c[p + q] = a[p++];
while (q < b.length)
    c[p + q] = b[q++];
return c;
voidmerge(int[] a, int[] temp, int fromIndex, int toIndex)
Helper method for #mergeSort(int[]) .
if (fromIndex < toIndex) {
    int middleIndex = (fromIndex + toIndex) / 2;
    merge(a, temp, fromIndex, middleIndex);
    merge(a, temp, middleIndex + 1, toIndex);
    finishMerge(a, temp, fromIndex, middleIndex, toIndex);
voidmerge(int[] array, int i, int mid, int max)
merge
int[] tmp = new int[max - i + 1];
int k = 0;
int left = i;
int right = mid + 1;
while ((left <= mid) && (right <= max)) {
    if (array[left] <= array[right])
        tmp[k++] = array[left++];
    else
...
int[]merge(int[] array1, int[] array2)
merge
int[] dest = new int[array1.length + array2.length];
System.arraycopy(array1, 0, dest, 0, array1.length);
System.arraycopy(array2, 0, dest, array1.length, array2.length);
return dest;
int[]merge(int[] x1, int[] x2)
merge
int[] y = null;
int ylen = 0;
if (x1 != null)
    ylen += x1.length;
if (x2 != null)
    ylen += x2.length;
y = new int[ylen];
int pos = 0;
...
int[]merge(int[]... arrs)
merge
int[] result = new int[0];
if (arrs != null) {
    int count = 0;
    for (int i = 0; i < arrs.length; i++) {
        count += arrs[i].length;
    result = new int[count];
    int arg;
...
voidmerge(long[] theArray, long[] workSpace, int lowPtr, int highPtr, int upperBound)
merge
int j = 0; 
int lowerBound = lowPtr;
int mid = highPtr - 1;
int n = upperBound - lowerBound + 1; 
while (lowPtr <= mid && highPtr <= upperBound)
    if (theArray[lowPtr] < theArray[highPtr])
        workSpace[j++] = theArray[lowPtr++];
    else
...
Object[][]merge(Object[][] array1, Object[][] array2)
merge
if (array1 == null) {
    array1 = new Object[0][0];
if (array2 == null) {
    array2 = new Object[0][0];
int z = 0;
if (array1 != null && array1.length > 0) {
...
Stringmerge(String array[], String delimiter)
merge
if (array == null) {
    return null;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; i++) {
    sb.append(array[i].trim());
    if ((i + 1) != array.length) {
        sb.append(delimiter);
...
Stringmerge(String[] array)
merge
return Arrays.asList(array).stream().reduce((a, b) -> a + b).get();