Here you can find the source of createTuple(List> tuples, List
Parameter | Description |
---|---|
T | a parameter |
tuples | a parameter |
entries | a parameter |
lists | a parameter |
static <T> void createTuple(List<List<T>> tuples, List<T> entries, List<Collection<T>> lists)
//package com.java2s; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { /**/*from w w w . j a v a2 s .c o m*/ * This recursive method is used by the computeCombinations() method. It * recursively adds tuples to the input tuples list as they are formed. * * @param <T> * @param tuples * @param entries * @param lists */ static <T> void createTuple(List<List<T>> tuples, List<T> entries, List<Collection<T>> lists) { if (entries.size() == lists.size() - 1) { for (T t : lists.get(entries.size())) { List<T> tuple = new ArrayList<T>(entries); tuple.add(t); tuples.add(tuple); } } else { for (T t : lists.get(entries.size())) { List<T> updatedEntries = new ArrayList<T>(entries); updatedEntries.add(t); createTuple(tuples, updatedEntries, lists); } } } }