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


Java Factory.createPermutationWithRepetitionGenerator方法代码示例

本文整理汇总了Java中org.paukov.combinatorics.Factory.createPermutationWithRepetitionGenerator方法的典型用法代码示例。如果您正苦于以下问题:Java Factory.createPermutationWithRepetitionGenerator方法的具体用法?Java Factory.createPermutationWithRepetitionGenerator怎么用?Java Factory.createPermutationWithRepetitionGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.paukov.combinatorics.Factory的用法示例。


在下文中一共展示了Factory.createPermutationWithRepetitionGenerator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createStates

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
public void createStates()
{
	// Create the initial vector of 2 elements (0 and 1 to represent black and white)
	ICombinatoricsVector<Integer> originalVector = Factory.createVector(new Integer[] { 0, 1 });

	// Set the second parameter as 9, since we are permutating with 9 discs.
	Generator<Integer> gen = Factory.createPermutationWithRepetitionGenerator(originalVector, 9);
	
	for (ICombinatoricsVector<Integer> permuation : gen) 
	{
		int[][] generatedState = new int[3][3];
		List<Integer> listOfGeneratedStates = permuation.getVector();
		int numOfState = 0;
		for(int y = 0; y < 3; y++)
		{
			for(int x = 0; x < 3; x++)
			{
			generatedState[x][y] = listOfGeneratedStates.get(numOfState);
			
			numOfState++;
			}
		}
		setOfStates.add(generatedState);
	}
}
 
开发者ID:sunhuts,项目名称:FlipItQ,代码行数:26,代码来源:QMatrix.java

示例2: permutation_with_repetitions

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
static void permutation_with_repetitions() {

        System.out.println("===== Permutation With Repetitions: =====");

        // Create the initial set/vector of 2 elements (apple, orange)
        ICombinatoricsVector<String> originalVector = Factory
                .createVector(new String[]{"apple", "orange"});

        // Create the generator by calling the appropriate method in the Factory
        // class
        Generator<String> gen = Factory
                .createPermutationWithRepetitionGenerator(originalVector, 3);

        // Print the result
        for (ICombinatoricsVector<String> perm : gen)
            System.out.println(perm);

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

示例3: generateInterfaceMethodsForStaticCallsWithMaxNumOfArgs

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
private void generateInterfaceMethodsForStaticCallsWithMaxNumOfArgs(StringBuilder javaFile,
		ICombinatoricsVector<MethodParameter> originalVector, List<String> returnTypes, int numberOfParams) {
	Generator<MethodParameter> gen = Factory.createPermutationWithRepetitionGenerator(originalVector, numberOfParams);
	for (String returnTypeAsString : returnTypes) {
		for (ICombinatoricsVector<MethodParameter> paramType : gen) {
			if (paramType.getVector().get(0) == MethodParameter.OBJECT) {
				String parameters = getParametersString(paramType, javaFile);
				javaFile.append(NEWLINE_TAB).append(returnTypeAsString).append(getSignatureExclArgsAndReturn(returnTypeAsString)).append(parameters).append(END_OF_SIGNATURE);
			}
		}
	}
}
 
开发者ID:Hervian,项目名称:lambda-factory,代码行数:13,代码来源:GenerateLambdaProcessor.java

示例4: generateInterfaceMethodCombinationsRecursively

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
private void generateInterfaceMethodCombinationsRecursively(StringBuilder javaFile,
		ICombinatoricsVector<MethodParameter> originalVector, List<String> returnTypes, int numberOfParams) {
	if (numberOfParams >= 0) {
		javaFile.append(NEWLINE);
		Generator<MethodParameter> gen = Factory.createPermutationWithRepetitionGenerator(originalVector, numberOfParams);
		for (String returnTypeAsString : returnTypes) {
			generateInterfaceMethods(gen, returnTypeAsString, javaFile);
		}
		generateInterfaceMethodCombinationsRecursively(javaFile, originalVector, returnTypes, --numberOfParams);
	}
}
 
开发者ID:Hervian,项目名称:lambda-factory,代码行数:12,代码来源:GenerateLambdaProcessor.java

示例5: simpleTreeOnePermutationWithRepetition

import org.paukov.combinatorics.Factory; //导入方法依赖的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

示例6: simpleThreeZeroPermutationWithRepetition

import org.paukov.combinatorics.Factory; //导入方法依赖的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

示例7: simpleOneOnePermutationWithRepetition

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleOneOnePermutationWithRepetition() {

	ICombinatoricsVector<Integer> coreVector = Factory
			.createVector(new Integer[] { 1 });

	Generator<Integer> permutationWithRepetitionGenerator = Factory.createPermutationWithRepetitionGenerator(
			coreVector, 1);
	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=([1], size=1)", list.get(0)
			.toString());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:32,代码来源:PermutationWithRepetitionsTest.java

示例8: simpleOneTwoPermutationWithRepetition

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleOneTwoPermutationWithRepetition() {

	ArrayList<Integer> array = new ArrayList<Integer>();
	array.add(1);

	ICombinatoricsVector<Integer> coreVector = Factory.createVector(array);

	Generator<Integer> permutationWithRepetitionGenerator = Factory.createPermutationWithRepetitionGenerator(
			coreVector, 2);
	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=([1, 1], size=2)", list.get(0)
			.toString());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:34,代码来源:PermutationWithRepetitionsTest.java

示例9: simpleOneZeroPermutationWithRepetition

import org.paukov.combinatorics.Factory; //导入方法依赖的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

示例10: threeTuplesOfTwoElements

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void threeTuplesOfTwoElements() {

	ICombinatoricsVector<Integer> originalVector = Factory
			.createVector(new Integer[] { 0, 1 });
	Generator<Integer> generator = Factory.createPermutationWithRepetitionGenerator(
			originalVector, 3);

	assertEquals(8, generator.getNumberOfGeneratedObjects());
	System.out.println("Number of permutations is: "
			+ generator.getNumberOfGeneratedObjects());

	for (ICombinatoricsVector<Integer> perm : generator)	{
			System.out.println("threeTuplesOfTwoElements " + perm);
	}

	List<ICombinatoricsVector<Integer>> list = generator
			.generateAllObjects();

	assertEquals(8, list.size());
	
	assertEquals("CombinatoricsVector=([0, 0, 0], size=3)", list.get(0)
			.toString());
	assertEquals("CombinatoricsVector=([1, 0, 0], size=3)", list.get(1)
			.toString());
	assertEquals("CombinatoricsVector=([0, 1, 0], size=3)", list.get(2)
			.toString());
	assertEquals("CombinatoricsVector=([1, 1, 0], size=3)", list.get(3)
			.toString());
	assertEquals("CombinatoricsVector=([0, 0, 1], size=3)", list.get(4)
			.toString());
	assertEquals("CombinatoricsVector=([1, 0, 1], size=3)", list.get(5)
			.toString());
	assertEquals("CombinatoricsVector=([0, 1, 1], size=3)", list.get(6)
			.toString());
	assertEquals("CombinatoricsVector=([1, 1, 1], size=3)", list.get(7)
			.toString());
	
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:40,代码来源:PermutationWithRepetitionsTest.java

示例11: simpleTreeTwoPermutationWithRepetition

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleTreeTwoPermutationWithRepetition() {

	ICombinatoricsVector<Integer> coreVector = Factory
			.createVector(new Integer[] { 1, 2, 3 });

	Generator<Integer> permutationWithRepetitionGenerator = Factory.createPermutationWithRepetitionGenerator(
			coreVector, 2);
	Iterator<ICombinatoricsVector<Integer>> permutationWithRepetitionIterator = permutationWithRepetitionGenerator
			.iterator();

	assertEquals(9,
			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(9, list.size());

	assertEquals("CombinatoricsVector=([1, 1], size=2)", list.get(0)
			.toString());
	assertEquals("CombinatoricsVector=([2, 1], size=2)", list.get(1)
			.toString());
	assertEquals("CombinatoricsVector=([3, 1], size=2)", list.get(2)
			.toString());
	assertEquals("CombinatoricsVector=([1, 2], size=2)", list.get(3)
			.toString());
	assertEquals("CombinatoricsVector=([2, 2], size=2)", list.get(4)
			.toString());
	assertEquals("CombinatoricsVector=([3, 2], size=2)", list.get(5)
			.toString());
	assertEquals("CombinatoricsVector=([1, 3], size=2)", list.get(6)
			.toString());
	assertEquals("CombinatoricsVector=([2, 3], size=2)", list.get(7)
			.toString());
	assertEquals("CombinatoricsVector=([3, 3], size=2)", list.get(8)
			.toString());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:48,代码来源:PermutationWithRepetitionsTest.java

示例12: sizeofThreePermutations

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void sizeofThreePermutations() {

	ICombinatoricsVector<String> originalVector = Factory
			.createVector(new String[] { "a", "b", "c", "d" });
	Generator<String> generator = Factory.createPermutationWithRepetitionGenerator(
			originalVector, 3);

	assertEquals(64, generator.getNumberOfGeneratedObjects());
	System.out.println("Number of permutations is: "
			+ generator.getNumberOfGeneratedObjects());

	for (ICombinatoricsVector<String> perm : generator)	{
			System.out.println("sizeofThreePermutations " + perm);
	}

	List<ICombinatoricsVector<String>> list = generator
			.generateFilteredObjects(new IFilter<ICombinatoricsVector<String>>() {
				@Override
				public boolean accepted(long index, ICombinatoricsVector<String> value) {
					return (!value.hasDuplicates());
				}
			});

	assertEquals(24, list.size());
	
	assertEquals("CombinatoricsVector=([c, b, a], size=3)", list.get(0)
			.toString());
	assertEquals("CombinatoricsVector=([d, b, a], size=3)", list.get(1)
			.toString());
	assertEquals("CombinatoricsVector=([b, c, a], size=3)", list.get(2)
			.toString());
	assertEquals("CombinatoricsVector=([d, c, a], size=3)", list.get(3)
			.toString());
	assertEquals("CombinatoricsVector=([b, d, a], size=3)", list.get(4)
			.toString());
	assertEquals("CombinatoricsVector=([c, d, a], size=3)", list.get(5)
			.toString());
	assertEquals("CombinatoricsVector=([c, a, b], size=3)", list.get(6)
			.toString());
	assertEquals("CombinatoricsVector=([d, a, b], size=3)", list.get(7)
			.toString());
	assertEquals("CombinatoricsVector=([a, c, b], size=3)", list.get(8)
			.toString());
	assertEquals("CombinatoricsVector=([d, c, b], size=3)", list.get(9)
			.toString());
	assertEquals("CombinatoricsVector=([a, d, b], size=3)", list.get(10)
			.toString());
	assertEquals("CombinatoricsVector=([c, d, b], size=3)", list.get(11)
			.toString());
	assertEquals("CombinatoricsVector=([b, a, c], size=3)", list.get(12)
			.toString());
	assertEquals("CombinatoricsVector=([d, a, c], size=3)", list.get(13)
			.toString());
	assertEquals("CombinatoricsVector=([a, b, c], size=3)", list.get(14)
			.toString());
	assertEquals("CombinatoricsVector=([d, b, c], size=3)", list.get(15)
			.toString());
	assertEquals("CombinatoricsVector=([a, d, c], size=3)", list.get(16)
			.toString());
	assertEquals("CombinatoricsVector=([b, d, c], size=3)", list.get(17)
			.toString());
	assertEquals("CombinatoricsVector=([b, a, d], size=3)", list.get(18)
			.toString());
	assertEquals("CombinatoricsVector=([c, a, d], size=3)", list.get(19)
			.toString());
	assertEquals("CombinatoricsVector=([a, b, d], size=3)", list.get(20)
			.toString());
	assertEquals("CombinatoricsVector=([c, b, d], size=3)", list.get(21)
			.toString());
	assertEquals("CombinatoricsVector=([a, c, d], size=3)", list.get(22)
			.toString());
	assertEquals("CombinatoricsVector=([b, c, d], size=3)", list.get(23)
			.toString());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:76,代码来源:PermutationWithRepetitionsTest.java


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