Java List Merge mergeCollectionsToList(Collection... cols)

Here you can find the source of mergeCollectionsToList(Collection... cols)

Description

merge Collections To List

License

Open Source License

Declaration

public static <T> List<T> mergeCollectionsToList(Collection<T>... cols) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static <T> List<T> mergeCollectionsToList(Collection<T>... cols) {
        List<T> mergedList = new ArrayList<T>(countCollectionsSize(cols));
        for (Collection<T> oneList : cols) {
            if (oneList == null)
                continue;
            mergedList.addAll(oneList);/*from   w  ww . j  a v  a  2 s .  c  o m*/
        }
        return mergedList;
    }

    public static int countCollectionsSize(Collection... cols) {
        int totalSize = 0;
        if (cols == null || cols.length < 1)
            return totalSize;
        for (Collection oneList : cols) {
            if (oneList == null)
                continue;
            totalSize += oneList.size();
        }
        return totalSize;
    }
}

Related

  1. merge(List list, List items)
  2. merge(String[] list)
  3. merge2ListsWithoutDup(List list1, List list2)
  4. mergeBandY(List A, int z, int y, int yn)
  5. mergeBytes(List packages)
  6. mergeCoords(List x, List y)
  7. mergeData(List lstMain, List lstData, List lstKey)
  8. mergedView(final List left, final List right)
  9. mergeErrorMsgList(List errorMsgs)