Java Utililty Methods List Merge

List of utility methods to do List Merge

Description

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

Method

Stringmerge(List text)
merge
StringBuilder builder = new StringBuilder();
for (String s : text) {
    builder.append(s);
return builder.toString();
ArrayListmerge(List a, List b)
merge
if (a == null && b == null)
    return null;
else if (a == null)
    return new ArrayList<>(b);
else if (b == null)
    return new ArrayList<>(a);
ArrayList<T> al = new ArrayList<>(a.size() + b.size());
al.addAll(a);
...
voidmerge(List a, List b, Comparator comp)
merge
b.addAll(a);
b.sort(comp);
voidmerge(List list)
merge
Collections.sort(list);
voidmerge(List list, int split)
Merges two consecutive sorted lists in place.
int n = list.size();
if (0 < split && split < n) {
    merge(list, 0, split, n - 1, (int) Math.sqrt(split), 0);
Listmerge(List list, List items)
merge
if (list != null) {
    if (items != null) {
        for (T item : items) {
            if (!list.contains(item)) {
                list.add(item);
} else {
    return items;
return list;
Stringmerge(String[] list)
merge
return merge(Arrays.asList(list));
Listmerge2ListsWithoutDup(List list1, List list2)
merge Lists Without Dup
list1.removeAll(list2);
list1.addAll(list2);
return list1;
voidmergeBandY(List A, int z, int y, int yn)
Auxilliary method required for merging two consecutive sorted lists in place.
while (z < y && y <= yn) {
    int j = z + indexOfMin(A.subList(z, y));
    if (A.get(j).compareTo(A.get(y)) <= 0) {
        Collections.swap(A, z, j);
    } else {
        Collections.swap(A, z, y);
        y++;
    z++;
if (z < y) {
    Collections.sort(A.subList(z, yn + 1));
byte[]mergeBytes(List packages)
merge Bytes
int len = 0;
for (byte[] aPackage : packages) {
    len += aPackage.length;
byte[] result = new byte[len];
int pos = 0;
for (byte[] aPackage : packages) {
    for (int j = 0; j < aPackage.length; j++) {
...