本文整理汇总了Java中org.paukov.combinatorics.Factory.createMultiCombinationGenerator方法的典型用法代码示例。如果您正苦于以下问题:Java Factory.createMultiCombinationGenerator方法的具体用法?Java Factory.createMultiCombinationGenerator怎么用?Java Factory.createMultiCombinationGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.paukov.combinatorics.Factory
的用法示例。
在下文中一共展示了Factory.createMultiCombinationGenerator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: multi_combinations
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
static void multi_combinations() {
System.out.println("===== Multi Combinations: =====");
// Create the initial vector of (apple, orange)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[]{"apple", "orange"});
// Create a multi-combination generator to generate 3-combinations of
// the initial vector
Generator<String> gen = Factory.createMultiCombinationGenerator(
initialVector, 3);
// Print all possible combinations
for (ICombinatoricsVector<String> combination : gen) {
System.out.println(combination);
}
}
示例2: multiCombination
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
public static ArrayList<List<Character>> multiCombination(Character[] elements, int K){
// Create the initial vector
ICombinatoricsVector<Character> initialVector = Factory.createVector(elements);
// Create a simple combination generator to generate 3-combinations of the initial vector
Generator<Character> gen = Factory.createMultiCombinationGenerator(initialVector, K);
// Locate all possible combinations
ArrayList<List<Character>> combinations = new ArrayList<List<Character>>();
for (ICombinatoricsVector<Character> combination : gen) {
combinations.add(combination.getVector());
}
return combinations;
}
示例3: multiCombinationOneTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void multiCombinationOneTest() {
// create array of initial items
List<String> array = new ArrayList<String>();
array.add("A");
// create combinatorics vector
ICombinatoricsVector<String> initialVector = Factory.createVector(
array);
// create multi-combination generator to generate 3-combination
Generator<String> gen = Factory.createMultiCombinationGenerator(
initialVector, 3);
// create iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// print the number of combinations
assertEquals(1, gen.getNumberOfGeneratedObjects());
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([A, A, A], size=3)", list.get(0)
.toString());
}
示例4: multiCombinationEmptyTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void multiCombinationEmptyTest() {
// create combinatorics vector
ICombinatoricsVector<String> initialVector = Factory.createVector(new String[] { "A", "B" });
// create multi-combination generator to generate 0-combination
Generator<String> gen = Factory.createMultiCombinationGenerator(
initialVector, 0);
// create iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// print the number of combinations
assertEquals(1, gen.getNumberOfGeneratedObjects());
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
}
示例5: multiCombinationEmptyEmptyTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void multiCombinationEmptyEmptyTest() {
// create array of initial empty items
List<String> array = new ArrayList<String>();
// create combinatorics vector
ICombinatoricsVector<String> initialVector = Factory.createVector(
array);
// create multi-combination generator to generate 0-combination
Generator<String> gen = Factory.createMultiCombinationGenerator(
initialVector, 0);
// create iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// print the number of combinations
assertEquals(1, gen.getNumberOfGeneratedObjects());
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
}
示例6: multiCombinationEmptyOneTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void multiCombinationEmptyOneTest() {
// create array of initial empty items
List<String> array = new ArrayList<String>();
// create combinatorics vector
ICombinatoricsVector<String> initialVector = Factory.createVector(
array);
// create multi-combination generator to generate 1-combination
Generator<String> gen = Factory.createMultiCombinationGenerator(
initialVector, 1);
// create iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// print the number of combinations
assertEquals(1, gen.getNumberOfGeneratedObjects());
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
}
示例7: multiCombinationMinusOneTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void multiCombinationMinusOneTest() {
// create combinatorics vector (A, B, C)
ICombinatoricsVector<String> initialVector = Factory.createVector(new String[] { "A", "B", "C" });
// create multi-combination generator to generate 3-combination
Generator<String> gen = Factory.createMultiCombinationGenerator(
initialVector, -1);
// create iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// print the number of combinations
assertEquals(1, gen.getNumberOfGeneratedObjects());
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
}
示例8: multiCombinationTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void multiCombinationTest() {
// create combinatorics vector
ICombinatoricsVector<String> initialVector = Factory.createVector(
new String[] { "A", "B", "C" });
// create multi-combination generator to generate 3-combination
Generator<String> gen = Factory.createMultiCombinationGenerator(
initialVector, 3);
// create iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// print the number of combinations
assertEquals(10, gen.getNumberOfGeneratedObjects());
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(10, list.size());
assertEquals("CombinatoricsVector=([A, A, A], size=3)", list.get(0)
.toString());
assertEquals("CombinatoricsVector=([A, A, B], size=3)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([A, A, C], size=3)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([A, B, B], size=3)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([A, B, C], size=3)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([A, C, C], size=3)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([B, B, B], size=3)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([B, B, C], size=3)", list.get(7)
.toString());
assertEquals("CombinatoricsVector=([B, C, C], size=3)", list.get(8)
.toString());
assertEquals("CombinatoricsVector=([C, C, C], size=3)", list.get(9)
.toString());
}
示例9: multiCombinationVectorsTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void multiCombinationVectorsTest() {
ICombinatoricsVector<String> vectorA = Factory
.createVector(new String[] { "A1", "A2", "A3" });
ICombinatoricsVector<String> vectorB = Factory
.createVector(new String[] { "B1", "B2", "B3" });
ICombinatoricsVector<String> vectorC = Factory
.createVector(new String[] { "C1", "C2", "C3" });
// create combinatorics vector
ICombinatoricsVector<ICombinatoricsVector<String>> initialVector = Factory.createVector();
initialVector.addValue(vectorA);
initialVector.addValue(vectorB);
initialVector.addValue(vectorC);
// create multi-combination generator to generate 3-combination
Generator<ICombinatoricsVector<String>> gen = Factory.createMultiCombinationGenerator(
initialVector, 3);
// create iterator
Iterator<ICombinatoricsVector<ICombinatoricsVector<String>>> itr = gen.iterator();
// print the number of combinations
assertEquals(10, gen.getNumberOfGeneratedObjects());
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<ICombinatoricsVector<String>> combination = itr.next();
String str = ComplexCombinationGenerator
.<String> convert2String(combination);
System.out.println(str + " = " + itr);
}
List<ICombinatoricsVector<ICombinatoricsVector<String>>> list = gen.generateAllObjects();
assertEquals(10, list.size());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([A1, A2, A3], size=3), CombinatoricsVector=([A1, A2, A3], size=3), CombinatoricsVector=([A1, A2, A3], size=3)], size=3)", list.get(0)
.toString());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([A1, A2, A3], size=3), CombinatoricsVector=([A1, A2, A3], size=3), CombinatoricsVector=([B1, B2, B3], size=3)], size=3)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([A1, A2, A3], size=3), CombinatoricsVector=([A1, A2, A3], size=3), CombinatoricsVector=([C1, C2, C3], size=3)], size=3)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([A1, A2, A3], size=3), CombinatoricsVector=([B1, B2, B3], size=3), CombinatoricsVector=([B1, B2, B3], size=3)], size=3)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([A1, A2, A3], size=3), CombinatoricsVector=([B1, B2, B3], size=3), CombinatoricsVector=([C1, C2, C3], size=3)], size=3)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([A1, A2, A3], size=3), CombinatoricsVector=([C1, C2, C3], size=3), CombinatoricsVector=([C1, C2, C3], size=3)], size=3)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([B1, B2, B3], size=3), CombinatoricsVector=([B1, B2, B3], size=3), CombinatoricsVector=([B1, B2, B3], size=3)], size=3)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([B1, B2, B3], size=3), CombinatoricsVector=([B1, B2, B3], size=3), CombinatoricsVector=([C1, C2, C3], size=3)], size=3)", list.get(7)
.toString());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([B1, B2, B3], size=3), CombinatoricsVector=([C1, C2, C3], size=3), CombinatoricsVector=([C1, C2, C3], size=3)], size=3)", list.get(8)
.toString());
assertEquals("CombinatoricsVector=([CombinatoricsVector=([C1, C2, C3], size=3), CombinatoricsVector=([C1, C2, C3], size=3), CombinatoricsVector=([C1, C2, C3], size=3)], size=3)", list.get(9)
.toString());
}