Java Collection Flatten flatten( Collection colOfCols)

Here you can find the source of flatten( Collection colOfCols)

Description

flatten

License

Apache License

Declaration

public static <T, C extends Collection<T>> List<T> flatten(
            Collection<C> colOfCols) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static <T, C extends Collection<T>> List<T> flatten(
            Collection<C> colOfCols) {
        int size = 0;
        for (C col : colOfCols) {
            size += col.size();//from  www  .ja  v a  2s  . c  om
        }
        ArrayList<T> list = new ArrayList<T>(size);
        for (C col : colOfCols) {
            list.addAll(col);
        }
        return list;
    }
}

Related

  1. flatten(Class cls, Collection> collections)
  2. flatten(Collection> collections)
  3. flatten(Collection> cols)
  4. flatten(Collection l)