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

Java ICombinatoricsVector类代码示例

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

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



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

示例1: createStates

import org.paukov.combinatorics.ICombinatoricsVector; //导入依赖的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.ICombinatoricsVector; //导入依赖的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: multi_combinations

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


示例4: permutation_with_repetitions

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


示例5: permutation_without_repetitions

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


示例6: complex_combination_indexes_example

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

        System.out.println("===== Complex Combination Indexes Example (List partitions): =====");

        // A list of elements
        String[] elements = new String[]{"A", "B", "B", "C"};

        // create a combinatorics vector of indexes (1, 1, 3)
        ICombinatoricsVector<Integer> indixesVector = Factory
                .createVector(new Integer[]{1, 1, 3});

        // Create a complex-combination generator
        Generator<ICombinatoricsVector<Integer>> complexGenerator = new ComplexCombinationGenerator<Integer>(
                indixesVector, 2);

        // Iterate the elements
        for (ICombinatoricsVector<ICombinatoricsVector<Integer>> combination : complexGenerator) {

            String str = ComplexCombinationGenerator.convertIndexes2String(
                    elements, combination);

            System.out.println(str);
        }
    }
 
开发者ID:dpaukov,项目名称:combinatoricslib,代码行数:25,代码来源:Main.java


示例7: complex_combination_example

import org.paukov.combinatorics.ICombinatoricsVector; //导入依赖的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: duplicate_subsets

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


示例9: simple_with_equal_elements_permutation

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


示例10: next

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


示例11: next

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


示例12: ComplexCombinationGenerator

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


示例13: convertIndexes2String

import org.paukov.combinatorics.ICombinatoricsVector; //导入依赖的package包/类
/**
 * This method converts a composition into a string
 * 
 * @param vector
 *            The vector
 * @return A string representation of the given vector
 */
public static <T> String convertIndexes2String(T[] elements,
		ICombinatoricsVector<ICombinatoricsVector<Integer>> vector) {
	StringBuilder sb = new StringBuilder();
	sb.append("(");
	for (int i = 0; i < vector.getSize(); i++) {
		sb.append("[");
		for (int j = 0; j < vector.getValue(i).getVector().size(); j++)	{
			sb.append(elements[vector.getValue(i).getValue(j)]);
			if (j != vector.getValue(i).getVector().size() - 1)
				sb.append(",");
		}
		sb.append("]");
		if (i != vector.getSize() - 1)
			sb.append(",");
	}
	sb.append(")");
	return sb.toString();

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


示例14: getCurrentItem

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


示例15: simpleEmptyPermutation

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


示例16: allIdenticalPermutation

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


示例17: simpleOneComposition

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

	Generator<Integer> compositionGenerator = Factory
			.createCompositionGenerator(1);
	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=([1], size=1)", list.get(0)
			.toString());

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


示例18: simpleEmptyPartition

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

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

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

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

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

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


示例19: permutation

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


示例20: multiCombination

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Parser类代码示例发布时间:2022-05-21
下一篇:
Java VersionListing类代码示例发布时间: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