当前位置: 首页>>代码示例>>Java>>正文


Java Generator.generateAllObjects方法代码示例

本文整理汇总了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());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:24,代码来源:PermutationsTest.java

示例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)));

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:34,代码来源:ComplexCombinationTest.java

示例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());

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:31,代码来源:PermutationWithRepetitionsTest.java

示例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)));

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:38,代码来源:ComplexCombinationTest.java

示例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());

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:32,代码来源:SimpleCombinationTest.java

示例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());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:38,代码来源:PartitionsTest.java

示例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());

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:29,代码来源:CompositionTest.java

示例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)));
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:33,代码来源:ComplexCombinationTest.java

示例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());

}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:34,代码来源:MultiCombinationsTest.java

示例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());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:40,代码来源:PermutationWithRepetitionsTest.java

示例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)));
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:33,代码来源:ComplexCombinationTest.java

示例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());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:33,代码来源:PermutationWithRepetitionsTest.java

示例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)));
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:53,代码来源:ComplexCombinationTest.java

示例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());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:60,代码来源:SubSetsTest.java

示例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());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:44,代码来源:SubSetsTest.java


注:本文中的org.paukov.combinatorics.Generator.generateAllObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。