• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Factory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Factory类属于org.paukov.combinatorics包,在下文中一共展示了Factory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: attrCombTest

import org.paukov.combinatorics.Factory; //导入依赖的package包/类
@Test
public void attrCombTest() {
  Attribute isbn = new Attribute("isbn", Type.TEXT);
  Attribute author = new Attribute("author", Type.TEXT);
  Attribute binding = new Attribute("binding", Type.TEXT);
  
  List<Attribute> attrs = new ArrayList<Attribute>();
  attrs.add(isbn);
  attrs.add(author);
  attrs.add(binding);
  
  ICombinatoricsVector<Attribute> initialVector = Factory.createVector(attrs);
  
  List<Attribute> newAttrs = (List<Attribute>) initialVector;
  
  System.out.println(newAttrs);

}
 
开发者ID:saikatgomes,项目名称:CS784-Data_Integration,代码行数:19,代码来源:AttrCombTest.java


示例3: simple_combinations

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

        System.out.println("===== Simple Combinations: =====");

        // Create the initial vector
        ICombinatoricsVector<String> initialVector = Factory
                .createVector(new String[]{"red", "black", "white", "green",
                        "blue"});

        // Create a simple combination generator to generate 3-combinations of
        // the initial vector
        Generator<String> gen = Factory.createSimpleCombinationGenerator(
                initialVector, 3);

        // Print all possible combinations
        for (ICombinatoricsVector<String> combination : gen) {
            System.out.println(combination);
        }

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


示例4: 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


示例5: 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


示例6: 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


示例7: complex_combination_example

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

        System.out.println("complexCombinationExample");
        System.out.println("===== Complex Combination Example: =====");

        // create a combinatorics vector (A, B, B, C)
        ICombinatoricsVector<String> vector = Factory
                .createVector(new String[]{"A", "B", "B", "C"});

        // Create a complex-combination generator
        Generator<ICombinatoricsVector<String>> gen = new ComplexCombinationGenerator<String>(
                vector, 2);

        // Iterate the combinations
        for (ICombinatoricsVector<ICombinatoricsVector<String>> comb : gen) {
            System.out.println(ComplexCombinationGenerator.convert2String(comb)
                    + " - " + comb);
        }
    }
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:20,代码来源:Main.java


示例8: simple_subsets

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

        System.out.println("===== All subsets: =====");

        // Create an initial vector/set
        ICombinatoricsVector<String> initialSet = Factory
                .createVector(new String[]{"one", "two", "three"});

        // Create an instance of the subset generator
        Generator<String> gen = Factory.createSubSetGenerator(initialSet);

        // Print the subsets
        for (ICombinatoricsVector<String> subSet : gen) {
            System.out.println(subSet);
        }
    }
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:17,代码来源:Main.java


示例9: duplicate_subsets

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

        System.out.println("===== All subsets with duplicates: =====");

        // Create an initial vector/set (a, b, a, c)
        ICombinatoricsVector<String> initialSet = Factory
                .createVector(new String[]{"a", "b", "a", "c"});

        // Create an instance of the subset generator
        Generator<String> gen = Factory
                .createSubSetGenerator(initialSet, false);

        // Print the subsets
        for (ICombinatoricsVector<String> subSet : gen) {
            System.out.println(subSet);
        }
    }
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:18,代码来源:Main.java


示例10: simpleFiveCompositionRange

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

	Generator<Integer> compositionGenerator = Factory
			.createCompositionGenerator(5);

	System.out.println("Number of compositions is: "
			+ compositionGenerator.getNumberOfGeneratedObjects());
	assertEquals(16, compositionGenerator.getNumberOfGeneratedObjects());

	List<ICombinatoricsVector<Integer>> list = compositionGenerator
			.generateObjectsRange(5, 7);

	assertEquals(3, list.size());

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


示例11: 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


示例12: simpleZeroComposition

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

	Generator<Integer> compositionGenerator = Factory
			.createCompositionGenerator(0);
	Iterator<ICombinatoricsVector<Integer>> compositionIterator = compositionGenerator
			.iterator();

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

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

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

	assertEquals(1, list.size());

	assertEquals("CombinatoricsVector=([0], size=1)", list.get(0)
			.toString());

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


示例13: PermutationWithRepetitionIterator

import org.paukov.combinatorics.Factory; //导入依赖的package包/类
/**
 * Constructor
 * 
 * @param generator
 *            Generator
 */
PermutationWithRepetitionIterator(
		PermutationWithRepetitionGenerator<T> generator) {
	_generator = generator;
	_n = generator.getOriginalVector().getSize();
	_k = generator.getPermutationLength();

	List<T> list = new ArrayList<T>(_k);
	T defaultValue = generator.getOriginalVector().getValue(0);
	for (int i = 0; i < _k; i++) {
		list.add(defaultValue);
	}

	_currentPermutation = Factory.createVector(list);

	_bitVector = new int[_k + 2];
	init();
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:24,代码来源:PermutationWithRepetitionIterator.java


示例14: next

import org.paukov.combinatorics.Factory; //导入依赖的package包/类
/**
 * Moves to the next permutation
 * 
 * @see Iterator#next()
 */
@Override
public ICombinatoricsVector<T> next() {
	_currentIndex++;

	for (int j = _k - 1; j >= 0; j--) {
		int index = _bitVector[j];
		_currentPermutation.setValue(j, _generator.getOriginalVector()
				.getValue(index));
	}

	int i = 0;
	while (_bitVector[i] == _n - 1) {
		if (i < _k + 1)
			_bitVector[i] = 0;
		else {
			_bitVector[_k] = 1;
			return Factory.createVector(_currentPermutation);
		}
		i++;
	}

	_bitVector[i]++;
	return Factory.createVector(_currentPermutation);

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


示例15: next

import org.paukov.combinatorics.Factory; //导入依赖的package包/类
/**
 * Returns the next subset if it is available
 * 
 * @see Iterator#next()
 */
@Override
public ICombinatoricsVector<T> next() {
	_currentIndex++;
	_currentSubSet.clearVector();
	for (int index = 1; index <= _length; index++) {
		if (_bitVector[index] == 1) {
			T value = _generator.getOriginalVector().getValue(index - 1);
			_currentSubSet.addValue(value);
		}
	}
	int i = 1;
	while (_bitVector[i] == 1) {
		_bitVector[i] = 0;
		i++;
	}
	_bitVector[i] = 1;

	return Factory.createVector(_currentSubSet);
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:25,代码来源:SubSetIterator.java


示例16: ComplexCombinationGenerator

import org.paukov.combinatorics.Factory; //导入依赖的package包/类
/**
 * Constructor
 * 
 * @param originalVector
 *            Original vector/set which is used for combination generation
 * @param combinationsLength
 *            Length of combination to generate
 * @param isOrderImportant
 *            true if the order of the generated combinations is important
 * @param excludeEmptySet
 *            true if the empty set has to be excluded from the generated
 *            combinations
 */
public ComplexCombinationGenerator(ICombinatoricsVector<T> originalVector,
		int combinationsLength, boolean isOrderImportant,
		boolean excludeEmptySet) {

	if (excludeEmptySet && combinationsLength > originalVector.getSize())
		throw new RuntimeException(
				"Unable to generate complex combinations, the requested combination length is more then the size of the original vector, length: "
						+ combinationsLength
						+ ", originalVector: "
						+ originalVector);

	_originalVector = Factory.createVector(originalVector);
	_combinationLength = combinationsLength;
	_isOrderImportant = isOrderImportant;
	_excludeEmptySet = excludeEmptySet;
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:30,代码来源:ComplexCombinationGenerator.java


示例17: getCurrentItem

import org.paukov.combinatorics.Factory; //导入依赖的package包/类
/**
 * Returns current composition
 */
private ICombinatoricsVector<Integer> getCurrentItem() {

	_currentComposition = Factory.<Integer> createVector();

	List<Integer> vector = _currentSubset.getVector();
	java.util.Iterator<Integer> itr = vector.iterator();

	int currentValueSubSet = 0;
	int indexCompositionElement = 0;
	int valueCompositionElement = 0;

	while (itr.hasNext()) {
		Integer currentSubsetElement = itr.next();
		valueCompositionElement = currentSubsetElement - currentValueSubSet;
		_currentComposition.setValue(indexCompositionElement,
				valueCompositionElement);
		indexCompositionElement++;
		currentValueSubSet = currentSubsetElement;
	}
	_currentComposition.setValue(indexCompositionElement,
			_generator._initialValue - currentValueSubSet);

	return _currentComposition;
}
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:28,代码来源:CompositionIterator.java


示例18: 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


示例19: 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


示例20: simpleOnePartition

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

	Generator<Integer> partitionGenerator = Factory
			.createPartitionGenerator(1);
	Iterator<ICombinatoricsVector<Integer>> partitionIterator = partitionGenerator
			.iterator();

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

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

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

	assertEquals(1, list.size());

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HelloMessage类代码示例发布时间:2022-05-21
下一篇:
Java ClientProtocol类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap