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


Java ICombinatoricsVector类代码示例

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


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


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