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

voidmerge(double[] a, int[] b, int p, int q, int r)
merge
double[] t = new double[r - p + 1];
int[] v = new int[r - p + 1];
int i, p1 = p, p2 = q + 1;
for (i = 0; p1 <= q && p2 <= r; ++i) {
    if (a[p1] < a[p2]) {
        v[i] = b[p1];
        t[i] = a[p1++];
    } else {
...
double[]merge(double[]... args)
merge
int size = 0;
for (int i = 0; i < args.length; i++) {
    size += args[i].length;
double[] merged = new double[size];
int start = 0;
for (int i = 0; i < args.length; i++) {
    System.arraycopy(args[i], 0, merged, start, args.length);
...
Listmerge(E[] a1, E[] a2)
merge
List<E> list = new ArrayList<E>();
for (int i = 0; i < a1.length; i++) {
    list.add(a1[i]);
for (int i = 0; i < a2.length; i++) {
    list.add(a2[i]);
return list;
...
E[]merge(E[] arrayA, E[] arrayB)
Merges the two arrays passed in argument into a single one, in the order specified.
E[] result = Arrays.copyOf(arrayA, arrayA.length + arrayB.length);
System.arraycopy(arrayB, 0, result, arrayA.length, arrayB.length);
return result;
byte[]merge(final byte[] b1, final byte[] b2)
merge
if (b1 == null) {
    throw new NullPointerException("b1 must not be null");
if (b2 == null) {
    throw new NullPointerException("b2 must not be null");
final byte[] result = new byte[b1.length + b2.length];
System.arraycopy(b1, 0, result, 0, b1.length);
...
byte[]merge(final byte[]... data)
merge
int size = 0;
for (final byte[] a : data)
    size += a.length;
final byte[] r = new byte[size];
for (final byte[] a : data)
    combine(r, a);
return r;
Listmerge(final String[] array1, final String[] array2)
merge
final List<String> prefixes = new ArrayList<String>();
addNoDuplicates(array1, prefixes);
addNoDuplicates(array2, prefixes);
return prefixes;
T[]merge(final T[] array1, final T[] array2)
merge
final T[] result = Arrays.copyOf(array1, array1.length + array2.length);
System.arraycopy(array2, 0, result, array1.length, array2.length);
return result;
voidmerge(int[] a, int l, int m, int h)
Merge the sorted sub-array a[l:m] with the sorted sub-array a[m+1:h], Cormen's single loop merge.
int[] L = new int[m - l + 2];
int[] R = new int[h - m + 1];
for (int i = l; i <= m; i++) {
    L[i - l] = a[i];
L[m - l + 1] = Integer.MAX_VALUE;
for (int i = m + 1; i <= h; i++) {
    R[i - m - 1] = a[i];
...
int[]merge(int[] a, int[] b)
Merges two sorted arrays to a single new array.
int[] toReturn = 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]) {
        toReturn[k] = a[i];
        i++;
    } else {
        toReturn[k] = b[j];
...