本文整理汇总了Java中org.paukov.combinatorics.Factory.createCompositionGenerator方法的典型用法代码示例。如果您正苦于以下问题:Java Factory.createCompositionGenerator方法的具体用法?Java Factory.createCompositionGenerator怎么用?Java Factory.createCompositionGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.paukov.combinatorics.Factory
的用法示例。
在下文中一共展示了Factory.createCompositionGenerator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simpleFiveCompositionRange
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleFiveCompositionRange() {
Generator<Integer> compositionGenerator = Factory
.createCompositionGenerator(5);
System.out.println("Number of compositions is: "
+ compositionGenerator.getNumberOfGeneratedObjects());
assertEquals(16, compositionGenerator.getNumberOfGeneratedObjects());
List<ICombinatoricsVector<Integer>> list = compositionGenerator
.generateObjectsRange(5, 7);
assertEquals(3, list.size());
assertEquals("CombinatoricsVector=([3, 2], size=2)", list.get(0)
.toString());
assertEquals("CombinatoricsVector=([1, 2, 2], size=3)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([2, 1, 2], size=3)", list.get(2)
.toString());
}
示例2: simpleOneComposition
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleOneComposition() {
Generator<Integer> compositionGenerator = Factory
.createCompositionGenerator(1);
Iterator<ICombinatoricsVector<Integer>> compositionIterator = compositionGenerator
.iterator();
System.out.println("Number of compositions is: "
+ compositionGenerator.getNumberOfGeneratedObjects());
assertEquals(1, compositionGenerator.getNumberOfGeneratedObjects());
while (compositionIterator.hasNext()) {
compositionIterator.next();
System.out.println(compositionIterator);
}
List<ICombinatoricsVector<Integer>> list = compositionGenerator
.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([1], size=1)", list.get(0)
.toString());
}
示例3: simpleZeroComposition
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleZeroComposition() {
Generator<Integer> compositionGenerator = Factory
.createCompositionGenerator(0);
Iterator<ICombinatoricsVector<Integer>> compositionIterator = compositionGenerator
.iterator();
System.out.println("Number of compositions is: "
+ compositionGenerator.getNumberOfGeneratedObjects());
assertEquals(1, compositionGenerator.getNumberOfGeneratedObjects());
while (compositionIterator.hasNext()) {
compositionIterator.next();
System.out.println(compositionIterator);
}
List<ICombinatoricsVector<Integer>> list = compositionGenerator
.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([0], size=1)", list.get(0)
.toString());
}
示例4: integer_composition
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
static void integer_composition() {
System.out.println("===== All integer combinations of 5: =====");
// Create an instance of the integer composition generator to generate
// all possible compositions of 5
Generator<Integer> gen = Factory.createCompositionGenerator(5);
// Print the compositions
for (ICombinatoricsVector<Integer> p : gen) {
System.out.println(p);
}
}
示例5: simpleTwoComposition
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleTwoComposition() {
Generator<Integer> compositionGenerator = Factory
.createCompositionGenerator(2);
Iterator<ICombinatoricsVector<Integer>> compositionIterator = compositionGenerator
.iterator();
System.out.println("Number of compositions is: "
+ compositionGenerator.getNumberOfGeneratedObjects());
assertEquals(2, compositionGenerator.getNumberOfGeneratedObjects());
while (compositionIterator.hasNext()) {
compositionIterator.next();
System.out.println(compositionIterator);
}
List<ICombinatoricsVector<Integer>> list = compositionGenerator
.generateAllObjects();
assertEquals(2, list.size());
assertEquals("CombinatoricsVector=([2], size=1)", list.get(0)
.toString());
assertEquals("CombinatoricsVector=([1, 1], size=2)", list.get(1)
.toString());
}
示例6: simpleFiveComposition
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleFiveComposition() {
Generator<Integer> compositionGenerator = Factory
.createCompositionGenerator(5);
Iterator<ICombinatoricsVector<Integer>> compositionIterator = compositionGenerator
.iterator();
System.out.println("Number of compositions is: "
+ compositionGenerator.getNumberOfGeneratedObjects());
assertEquals(16, compositionGenerator.getNumberOfGeneratedObjects());
while (compositionIterator.hasNext()) {
compositionIterator.next();
System.out.println(compositionIterator);
}
List<ICombinatoricsVector<Integer>> list = compositionGenerator
.generateAllObjects();
assertEquals(16, list.size());
assertEquals("CombinatoricsVector=([5], size=1)", list.get(0)
.toString());
assertEquals("CombinatoricsVector=([1, 4], size=2)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([2, 3], size=2)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([1, 1, 3], size=3)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([3, 2], size=2)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([1, 2, 2], size=3)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([2, 1, 2], size=3)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([1, 1, 1, 2], size=4)", list.get(7)
.toString());
assertEquals("CombinatoricsVector=([4, 1], size=2)", list.get(8)
.toString());
assertEquals("CombinatoricsVector=([1, 3, 1], size=3)", list.get(9)
.toString());
assertEquals("CombinatoricsVector=([2, 2, 1], size=3)", list.get(10)
.toString());
assertEquals("CombinatoricsVector=([1, 1, 2, 1], size=4)", list.get(11)
.toString());
assertEquals("CombinatoricsVector=([3, 1, 1], size=3)", list.get(12)
.toString());
assertEquals("CombinatoricsVector=([1, 2, 1, 1], size=4)", list.get(13)
.toString());
assertEquals("CombinatoricsVector=([2, 1, 1, 1], size=4)", list.get(14)
.toString());
assertEquals("CombinatoricsVector=([1, 1, 1, 1, 1], size=5)",
list.get(15).toString());
}