Java List Create createTuple(List> tuples, List entries, List> lists)

Here you can find the source of createTuple(List> tuples, List entries, List> lists)

Description

This recursive method is used by the computeCombinations() method.

License

Open Source License

Parameter

Parameter Description
T a parameter
tuples a parameter
entries a parameter
lists a parameter

Declaration

static <T> void createTuple(List<List<T>> tuples, List<T> entries, List<Collection<T>> lists) 

Method Source Code


//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);
            }
        }
    }
}

Related

  1. createSymbolNameString_From_Parts(List descTagName_Parts)
  2. createTable(List datas, String[] headers, int numColumns, int cellPadding, int border)
  3. createTagList(List tags, String separator)
  4. createTarget(List labels)
  5. createTargetSorted(List labels, Comparator comp)
  6. createUniqueProducts(List list1, List list2)
  7. createUnmodifiableList(Collection coll)
  8. createUpdateMeasurementItemList(final String itemList, final String updateItem)
  9. createValues(int barCount, String valueDigits, int distributionType, List valueCounts)