Java List Product product(List> lists)

Here you can find the source of product(List> lists)

Description

product

License

Apache License

Declaration

public static List<String[]> product(List<List<String>> lists) 

Method Source Code


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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static List<String[]> product(List<List<String>> lists) {
        List<String[]> results = new ArrayList<>();
        product(results, lists, 0, new String[lists.size()]);
        return results;
    }/*from w ww . ja v a  2 s.  com*/

    private static void product(List<String[]> results, List<List<String>> lists, int depth, String[] current) {
        for (int i = 0; i < lists.get(depth).size(); i++) {
            current[depth] = lists.get(depth).get(i);
            if (depth < lists.size() - 1)
                product(results, lists, depth + 1, current);
            else {
                results.add(Arrays.copyOf(current, current.length));
            }
        }
    }
}

Related

  1. dotProduct(List v1, List v2)
  2. dotProductValue(List oper1, List oper2)
  3. getProductsFromString(List projects)
  4. scalarProduct(List a, List b)
  5. scalerProduct(final List doubleList, final double scalerFactor)