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


Java Factory.createMultiCombinationGenerator方法代码示例

本文整理汇总了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);
        }

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

示例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;
}
 
开发者ID:c-zhou,项目名称:polyGembler,代码行数:13,代码来源:Combination.java

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

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

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

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

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

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

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

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

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

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


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