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

voidmerge(List original, List merger)
merge
int i;
for (i = 0; i < original.size() && i < merger.size(); i++) {
    merge(original.get(i), merger.get(i));
if (merger.size() > original.size()) {
    for (; i < merger.size(); i++)
        original.add(merger.get(i));
byte[]merge(List bs)
merge
int len = 0;
for (int i = 0; i < bs.size(); i++) {
    len += bs.get(i).length;
byte[] merged = new byte[len];
int x = 0;
for (int i = 0; i < bs.size(); i++) {
    byte[] b = bs.get(i);
...
Listmerge(List left, List right)
Helper method for the #mergeSort(List) method.
List<E> result = new ArrayList<E>();
Iterator<E> it1 = left.iterator();
Iterator<E> it2 = right.iterator();
E x = it1.next();
E y = it2.next();
while (true) {
    if (x.compareTo(y) <= 0) {
        result.add(x);
...
Listmerge(List list1, List list2)
Merges two sorted segments into a single sorted list.
List<K> newList = new ArrayList<>(list1.size() + list2.size());
int offset1 = 0;
int offset2 = 0;
while (!list1.isEmpty() && !list2.isEmpty()) {
    K item1 = list1.get(offset1);
    K item2 = list2.get(offset2);
    if (item1.compareTo(item2) <= 0) {
        newList.add(item1);
...
Listmerge(List> list)
merge
List<T> result = new ArrayList<>();
list.stream().forEach(result::addAll);
return result;
Listmerge(List l1, List l2)
merge
final List<O> result = new ArrayList<O>(l1);
result.addAll(l2);
return Collections.unmodifiableList(result);
Listmerge(List l1, List l2)
merge
if (isEmpty(l1)) {
    return l2;
if (isEmpty(l2)) {
    return l1;
for (String o : l2) {
    if (!l1.contains(o)) {
...
Stringmerge(List list)
merge
return merge(list, ",");
Listmerge(List lst1, List lst2)
Joins two lists in such a way that common end of the first list and common start with the second list are merged.
int rootStart = lst1.size() > lst2.size() ? lst1.size() - lst2.size() : 0;
int suffixEnd = lst2.size() > lst1.size() ? lst1.size() : lst2.size();
boolean ends = false;
while (rootStart < lst1.size() && suffixEnd >= 0) {
    ends = endsWith(lst1, head(lst2, suffixEnd));
    if (ends)
        break;
    rootStart++;
...
Stringmerge(List stringList)
Merges a string list into a single string without inserting any extra characters between strings.
StringBuilder stringBuilder = new StringBuilder();
for (String string : stringList) {
    stringBuilder.append(string);
return stringBuilder.toString();