本文整理汇总了Java中org.paukov.combinatorics.Generator.generateAllObjects方法的典型用法代码示例。如果您正苦于以下问题:Java Generator.generateAllObjects方法的具体用法?Java Generator.generateAllObjects怎么用?Java Generator.generateAllObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.paukov.combinatorics.Generator
的用法示例。
在下文中一共展示了Generator.generateAllObjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allIdenticalPermutation
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void allIdenticalPermutation() {
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "a", "a", "a" });
Generator<String> generator = Factory
.createPermutationGenerator(initialVector);
Iterator<ICombinatoricsVector<String>> iterator = generator.iterator();
while (iterator.hasNext()) {
iterator.next();
System.out.println(iterator);
}
List<ICombinatoricsVector<String>> list = generator
.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([a, a, a], size=3)", list.get(0)
.toString());
}
示例2: test8
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void test8() {
// create a combinatorics vector (a, b)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "a", "b" });
// Create a complex-combination generator and iterator
Generator<ICombinatoricsVector<String>> complexGenerator = new ComplexCombinationGenerator<String>(
initialVector, 1);
// Create a complex-combination iterator
Iterator<ICombinatoricsVector<ICombinatoricsVector<String>>> itr = complexGenerator
.iterator();
// Iterate the elements
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 = complexGenerator
.generateAllObjects();
assertEquals(1, list.size());
assertEquals("([a, b])",
ComplexCombinationGenerator.convert2String(list.get(0)));
}
示例3: simpleThreeZeroPermutationWithRepetition
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void simpleThreeZeroPermutationWithRepetition() {
ICombinatoricsVector<Integer> coreVector = Factory
.createVector(new Integer[] { 1, 2, 3 });
Generator<Integer> permutationWithRepetitionGenerator = Factory.createPermutationWithRepetitionGenerator(
coreVector, 0);
Iterator<ICombinatoricsVector<Integer>> permutationWithRepetitionIterator = permutationWithRepetitionGenerator
.iterator();
assertEquals(1,
permutationWithRepetitionGenerator
.getNumberOfGeneratedObjects());
System.out.println("Number of permutationWithRepetition is: "
+ permutationWithRepetitionGenerator
.getNumberOfGeneratedObjects());
while (permutationWithRepetitionIterator.hasNext()) {
permutationWithRepetitionIterator.next();
System.out.println(permutationWithRepetitionIterator);
}
List<ICombinatoricsVector<Integer>> list = permutationWithRepetitionGenerator
.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
}
示例4: test2
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void test2() {
// create a combinatorics vector (a, a, a, a)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "a", "a", "a", "a" });
// Create a complex-combination generator and iterator
Generator<ICombinatoricsVector<String>> complexGenerator = new ComplexCombinationGenerator<String>(
initialVector, 2, true, true);
// Create a complex-combination iterator
Iterator<ICombinatoricsVector<ICombinatoricsVector<String>>> itr = complexGenerator
.iterator();
// Iterate the elements
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 = complexGenerator
.generateAllObjects();
assertEquals(3, list.size());
assertEquals("([a],[a, a, a])",
ComplexCombinationGenerator.convert2String(list.get(0)));
assertEquals("([a, a, a],[a])",
ComplexCombinationGenerator.convert2String(list.get(1)));
assertEquals("([a, a],[a, a])",
ComplexCombinationGenerator.convert2String(list.get(2)));
}
示例5: simpleTwoTwoCombinationTest
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void simpleTwoTwoCombinationTest() {
// create combinatorics vector
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "red", "green" });
// create simple combination generator to generate 2-combination of 2
Generator<String> gen = Factory.createSimpleCombinationGenerator(
initialVector, 2);
// 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=([red, green], size=2)", list.get(0)
.toString());
}
示例6: simplePartition
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void simplePartition() {
Generator<Integer> partitionGenerator = Factory
.createPartitionGenerator(5);
Iterator<ICombinatoricsVector<Integer>> partitionIterator = partitionGenerator
.iterator();
System.out.println("Number of partition is: "
+ partitionGenerator.getNumberOfGeneratedObjects());
assertEquals(8, partitionGenerator.getNumberOfGeneratedObjects());
while (partitionIterator.hasNext()) {
partitionIterator.next();
System.out.println(partitionIterator);
}
List<ICombinatoricsVector<Integer>> list = partitionGenerator
.generateAllObjects();
assertEquals(7, list.size());
assertEquals("CombinatoricsVector=([1, 1, 1, 1, 1], size=5)",
list.get(0).toString());
assertEquals("CombinatoricsVector=([2, 1, 1, 1], size=4)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([2, 2, 1], size=3)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([3, 1, 1], size=3)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([3, 2], size=2)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([4, 1], size=2)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([5], size=1)", list.get(6)
.toString());
}
示例7: simpleTwoComposition
import org.paukov.combinatorics.Generator; //导入方法依赖的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());
}
示例8: test10
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void test10() {
// create a combinatorics vector (a)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "a" });
// Create a complex-combination generator and iterator
Generator<ICombinatoricsVector<String>> complexGenerator = new ComplexCombinationGenerator<String>(
initialVector, 1);
// Create a complex-combination iterator
Iterator<ICombinatoricsVector<ICombinatoricsVector<String>>> itr = complexGenerator
.iterator();
// Iterate the elements
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 = complexGenerator
.generateAllObjects();
assertEquals(1, list.size());
assertEquals("([a])",
ComplexCombinationGenerator.convert2String(list.get(0)));
}
示例9: multiCombinationEmptyEmptyTest
import org.paukov.combinatorics.Generator; //导入方法依赖的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());
}
示例10: simpleTreeOnePermutationWithRepetition
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void simpleTreeOnePermutationWithRepetition() {
ArrayList<Integer> array = new ArrayList<Integer>();
array.add(1);
array.add(2);
array.add(3);
ICombinatoricsVector<Integer> coreVector = Factory.createVector(array);
Generator<Integer> permutationWithRepetitionGenerator = Factory.createPermutationWithRepetitionGenerator(
coreVector, 1);
Iterator<ICombinatoricsVector<Integer>> permutationWithRepetitionIterator = permutationWithRepetitionGenerator
.iterator();
assertEquals(3,
permutationWithRepetitionGenerator
.getNumberOfGeneratedObjects());
System.out.println("Number of permutationWithRepetition is: "
+ permutationWithRepetitionGenerator
.getNumberOfGeneratedObjects());
while (permutationWithRepetitionIterator.hasNext()) {
permutationWithRepetitionIterator.next();
System.out.println(permutationWithRepetitionIterator);
}
List<ICombinatoricsVector<Integer>> list = permutationWithRepetitionGenerator
.generateAllObjects();
assertEquals(3, list.size());
assertEquals("CombinatoricsVector=([1], size=1)", list.get(0)
.toString());
assertEquals("CombinatoricsVector=([2], size=1)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([3], size=1)", list.get(2)
.toString());
}
示例11: test9
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void test9() {
// create a combinatorics vector (a, b)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "a", "b" });
// Create a complex-combination generator and iterator
Generator<ICombinatoricsVector<String>> complexGenerator = new ComplexCombinationGenerator<String>(
initialVector, 1, true, true);
// Create a complex-combination iterator
Iterator<ICombinatoricsVector<ICombinatoricsVector<String>>> itr = complexGenerator
.iterator();
// Iterate the elements
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 = complexGenerator
.generateAllObjects();
assertEquals(1, list.size());
assertEquals("([a, b])",
ComplexCombinationGenerator.convert2String(list.get(0)));
}
示例12: simpleOneZeroPermutationWithRepetition
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void simpleOneZeroPermutationWithRepetition() {
ArrayList<Integer> array = new ArrayList<Integer>();
array.add(1);
ICombinatoricsVector<Integer> coreVector = Factory.createVector(array);
Generator<Integer> permutationWithRepetitionGenerator = Factory.createPermutationWithRepetitionGenerator(
coreVector, 0);
Iterator<ICombinatoricsVector<Integer>> permutationWithRepetitionIterator = permutationWithRepetitionGenerator
.iterator();
assertEquals(1,
permutationWithRepetitionGenerator
.getNumberOfGeneratedObjects());
System.out.println("Number of permutationWithRepetition is: "
+ permutationWithRepetitionGenerator
.getNumberOfGeneratedObjects());
while (permutationWithRepetitionIterator.hasNext()) {
permutationWithRepetitionIterator.next();
System.out.println(permutationWithRepetitionIterator);
}
List<ICombinatoricsVector<Integer>> list = permutationWithRepetitionGenerator
.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
}
示例13: foreachTest
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void foreachTest() {
// create a combinatorics vector (a, b, c, d)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "a", "b", "c", "d" });
// Create a complex-combination generator and iterator
Generator<ICombinatoricsVector<String>> complexGenerator = new ComplexCombinationGenerator<String>(
initialVector, 2, true, false);
for (ICombinatoricsVector<ICombinatoricsVector<String>> element : complexGenerator)
System.out.println("For each: " + element);
List<ICombinatoricsVector<ICombinatoricsVector<String>>> list = complexGenerator
.generateAllObjects();
assertEquals(16, list.size());
assertEquals("([],[a, b, c, d])",
ComplexCombinationGenerator.convert2String(list.get(0)));
assertEquals("([a, b, c, d],[])",
ComplexCombinationGenerator.convert2String(list.get(1)));
assertEquals("([a],[b, c, d])",
ComplexCombinationGenerator.convert2String(list.get(2)));
assertEquals("([b, c, d],[a])",
ComplexCombinationGenerator.convert2String(list.get(3)));
assertEquals("([b],[a, c, d])",
ComplexCombinationGenerator.convert2String(list.get(4)));
assertEquals("([a, c, d],[b])",
ComplexCombinationGenerator.convert2String(list.get(5)));
assertEquals("([a, b],[c, d])",
ComplexCombinationGenerator.convert2String(list.get(6)));
assertEquals("([c, d],[a, b])",
ComplexCombinationGenerator.convert2String(list.get(7)));
assertEquals("([c],[a, b, d])",
ComplexCombinationGenerator.convert2String(list.get(8)));
assertEquals("([a, b, d],[c])",
ComplexCombinationGenerator.convert2String(list.get(9)));
assertEquals("([a, c],[b, d])",
ComplexCombinationGenerator.convert2String(list.get(10)));
assertEquals("([b, d],[a, c])",
ComplexCombinationGenerator.convert2String(list.get(11)));
assertEquals("([b, c],[a, d])",
ComplexCombinationGenerator.convert2String(list.get(12)));
assertEquals("([a, d],[b, c])",
ComplexCombinationGenerator.convert2String(list.get(13)));
assertEquals("([a, b, c],[d])",
ComplexCombinationGenerator.convert2String(list.get(14)));
assertEquals("([d],[a, b, c])",
ComplexCombinationGenerator.convert2String(list.get(15)));
}
示例14: complexSubsetTest
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void complexSubsetTest() {
// create a combinatorics vector (A, A, B, B, C)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "A", "A", "B", "B", "C" });
// create a sub-set generator
Generator<String> gen = Factory.createSubSetGenerator(initialVector);
// create an iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(18, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
assertEquals("CombinatoricsVector=([A], size=1)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([A, A], size=2)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([B], size=1)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([A, B], size=2)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([A, A, B], size=3)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([B, B], size=2)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([A, B, B], size=3)", list.get(7)
.toString());
assertEquals("CombinatoricsVector=([A, A, B, B], size=4)", list.get(8)
.toString());
assertEquals("CombinatoricsVector=([C], size=1)", list.get(9)
.toString());
assertEquals("CombinatoricsVector=([A, C], size=2)", list.get(10)
.toString());
assertEquals("CombinatoricsVector=([A, A, C], size=3)", list.get(11)
.toString());
assertEquals("CombinatoricsVector=([B, C], size=2)", list.get(12)
.toString());
assertEquals("CombinatoricsVector=([A, B, C], size=3)", list.get(13)
.toString());
assertEquals("CombinatoricsVector=([A, A, B, C], size=4)", list.get(14)
.toString());
assertEquals("CombinatoricsVector=([B, B, C], size=3)", list.get(15)
.toString());
assertEquals("CombinatoricsVector=([A, B, B, C], size=4)", list.get(16)
.toString());
assertEquals("CombinatoricsVector=([A, A, B, B, C], size=5)",
list.get(17).toString());
}
示例15: simpleSubsetTest
import org.paukov.combinatorics.Generator; //导入方法依赖的package包/类
@Test
public void simpleSubsetTest() {
// create a combinatorics vector (A, B, C)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "A", "B", "C" });
// create a sub-set generator
Generator<String> gen = Factory.createSubSetGenerator(initialVector);
// create an iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// verify the number of sunsets
assertEquals(8, 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(8, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
assertEquals("CombinatoricsVector=([A], size=1)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([B], size=1)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([A, B], size=2)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([C], size=1)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([A, C], size=2)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([B, C], size=2)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([A, B, C], size=3)", list.get(7)
.toString());
}