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


Java Factory.createPermutationGenerator方法代码示例

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


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

示例1: permutation_without_repetitions

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

        System.out.println("===== Permutations Without Repetitions: =====");

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

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

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

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

示例2: simple_with_equal_elements_permutation

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

        System.out.println("===== Simple With Equal Elements Permutations: =====");

        // Create the initial vector
        ICombinatoricsVector<Integer> initialVector = Factory
                .createVector(new Integer[]{1, 1, 2, 2});

        // Create the generator
        Generator<Integer> generator = Factory
                .createPermutationGenerator(initialVector);

        for (ICombinatoricsVector<Integer> perm : generator) {
            System.out.println(perm);
        }
    }
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:17,代码来源:Main.java

示例3: all_permutations_of_all_combination

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
/**
 * This example recreates the issue 14.
 * https://code.google.com/p/combinatoricslib/issues/detail?id=14
 *
 * It generates all permutations of a given length where repetition is NOT allowed,
 * from a larger set of elements.
 */
static void all_permutations_of_all_combination() {

    System.out.println("===== All permutations of all combination: =====");

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

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

    // Print all permutations for all simple 3-combinations
    for (ICombinatoricsVector<String> comb : combinations){
        Generator<String> permutations = Factory.createPermutationGenerator(comb);
        for(ICombinatoricsVector<String> perm : permutations){
            System.out.println(perm);
        }
    }
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:28,代码来源:Main.java

示例4: simpleEmptyPermutation

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

	ArrayList<Integer> array = new ArrayList<Integer>();

	ICombinatoricsVector<Integer> corePermutation = Factory
			.createVector(array);
	Generator<Integer> generator = Factory
			.createPermutationGenerator(corePermutation);

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

	Iterator<ICombinatoricsVector<Integer>> iterator = generator.iterator();

	while (iterator.hasNext()) {
		iterator.next();
		System.out.println(iterator);
	}

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

	assertEquals(0, list.size());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:27,代码来源:PermutationsTest.java

示例5: allIdenticalPermutation

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

示例6: permutation

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
public static ArrayList<List<Character>> permutation(Character[]  elements){
	// 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.createPermutationGenerator(initialVector);
	// Locate all possible combinations
	ArrayList<List<Character>> permutations = new ArrayList<List<Character>>();
	for (ICombinatoricsVector<Character> combination : gen) {
		permutations.add(combination.getVector());
	}
	return permutations;
}
 
开发者ID:c-zhou,项目名称:polyGembler,代码行数:13,代码来源:Permutation.java

示例7: setUpWalkers

import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
private List<RelevanceAutomatonWalker> setUpWalkers() {
	SortedSet<Character> alphabetWithoutWildcard = this.vacuAwaWildAuto.getAlphabetWithoutWildcard();
	int k = alphabetWithoutWildcard.size();

	Set<Character> taskIdentifiersInLog = this.logTranslationMap.keySet();
	
	if (taskIdentifiersInLog.size() < k) {
		throw new IllegalArgumentException("Not enough tasks in the log to instanciate the constraint");
	}

	ICombinatoricsVector<Character> initialVector =
			Factory.createVector(taskIdentifiersInLog.toArray(new Character[k+1]));
	Iterator<ICombinatoricsVector<Character>> combosPermIterator = null;
	Generator<Character>
		comboGen = Factory.createSimpleCombinationGenerator(initialVector, k),
		combosPermGen = null;
	ArrayList<RelevanceAutomatonWalker> walkers = new ArrayList<RelevanceAutomatonWalker>();
	List<Character> vectorOfChars = null;
	int i = 0;
	for (ICombinatoricsVector<Character> simpleCombo : comboGen) {
		combosPermGen = Factory.createPermutationGenerator(simpleCombo);
		combosPermIterator = combosPermGen.iterator();
		while (combosPermIterator.hasNext()) {
			vectorOfChars = combosPermIterator.next().getVector();
			walkers.add(i++, new RelevanceAutomatonWalker(
					vectorOfChars,
					alphabetWithoutWildcard,
					logTranslationMap,
					vacuAwaWildAuto.getInitialWildState()));
		}
	}

	return walkers;
}
 
开发者ID:cdc08x,项目名称:MINERful,代码行数:35,代码来源:RelevanceAutomatonMultiWalker.java

示例8: simplePermutation

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

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

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

	Iterator<ICombinatoricsVector<Integer>> iterator = generator.iterator();

	while (iterator.hasNext()) {
		iterator.next();
		System.out.println(iterator);
	}

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

	assertEquals(6, list.size());

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

示例9: simpleOnePermutation

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

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

	ICombinatoricsVector<Integer> corePermutation = Factory
			.createVector(array);
	Generator<Integer> generator = Factory
			.createPermutationGenerator(corePermutation);

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

	Iterator<ICombinatoricsVector<Integer>> iterator = generator.iterator();

	while (iterator.hasNext()) {
		iterator.next();
		System.out.println(iterator);
	}

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

	assertEquals(1, list.size());

	assertEquals("CombinatoricsVector=([1], size=1)", list.get(0)
			.toString());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:31,代码来源:PermutationsTest.java

示例10: identicalPermutation

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

	ICombinatoricsVector<String> initialVector = Factory
			.createVector(new String[] { "a", "a", "b" });
	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(3, list.size());

	assertEquals("CombinatoricsVector=([a, a, b], size=3)", list.get(0)
			.toString());
	assertEquals("CombinatoricsVector=([a, b, a], size=3)", list.get(1)
			.toString());
	assertEquals("CombinatoricsVector=([b, a, a], size=3)", list.get(2)
			.toString());
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:28,代码来源:PermutationsTest.java

示例11: identicalPermutationTreatAsIdentical

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

	ICombinatoricsVector<String> initialVector = Factory
			.createVector(new String[] { "a", "a", "b" });
	
	Generator<String> generator = Factory
			.createPermutationGenerator(initialVector, true);

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

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

	assertEquals(6, list.size());

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

示例12: allIdenticalPermutationTreatAsIdentical

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

	ICombinatoricsVector<String> initialVector = Factory
			.createVector(new String[] { "x", "x" ,"x"});
	Generator<String> generator = Factory
			.createPermutationGenerator(initialVector, true);

	Iterator<ICombinatoricsVector<String>> iterator = generator.iterator();

	while (iterator.hasNext()) {
		iterator.next();
		System.out.println(iterator);
	}

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

	assertEquals(6, list.size());

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

示例13: abcPermutation

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

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

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

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

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

	assertEquals(6, list.size());

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

示例14: anyExpressionPermutation

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

	ICombinatoricsVector<String> originalVector = Factory
			.createVector(new String[] { "x", "x^2", "x+1" });
	Generator<String> generator = Factory
			.createPermutationGenerator(originalVector);

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

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

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

	assertEquals(6, list.size());

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

示例15: simpleWithEqualElementsPermutation

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

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

	Generator<Integer> generator = Factory
			.createPermutationGenerator(corePermutation);

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

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

	assertEquals(12, list.size());

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


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