本文整理汇总了Java中org.paukov.combinatorics.Factory.createVector方法的典型用法代码示例。如果您正苦于以下问题:Java Factory.createVector方法的具体用法?Java Factory.createVector怎么用?Java Factory.createVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.paukov.combinatorics.Factory
的用法示例。
在下文中一共展示了Factory.createVector方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
}
示例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;
}
示例7: multiCombination
import org.paukov.combinatorics.Factory; //导入方法依赖的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;
}
示例8: generateAbstractMethods
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
private void generateAbstractMethods(StringBuilder javaFile, MethodParameter[] types, int maxNumberOfParams) {
List<String> returnTypes = Arrays.asList(types).stream().map(type -> type.getTypeAsSourceCodeString()).collect(Collectors.toList());
returnTypes.add("void");
ICombinatoricsVector<MethodParameter> originalVector = Factory.createVector(types);
generateInterfaceMethodsForStaticCallsWithMaxNumOfArgs(javaFile, originalVector, returnTypes, maxNumberOfParams + 1);
generateInterfaceMethodCombinationsRecursively(javaFile, originalVector, returnTypes, maxNumberOfParams);
}
示例9: permutations
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
public static List<List<Field>> permutations(final List<Field> fields) {
final ICombinatoricsVector<Field> vector = Factory.createVector(fields);
final Generator<Field> subSetGenerator = Factory.createSubSetGenerator(vector);
return subSetGenerator.generateAllObjects()
.stream()
.map(ICombinatoricsVector::getVector)
.filter(FieldUtils::excludeEmptySet)
.collect(Collectors.toList());
}
示例10: createInitialPairings
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
/**
* Creates the initial set of pairings between Player objects. These Player objects
* are not the PlayerA and PlayerB child class objects created later. The number of
* players is calculated by calculating the number of non-repeating combinations.
*
* @param playersSet
* the players set
* @return the hash map
*/
private HashMap<Long, List<Player>> createInitialPairings(final Set<Player> playersSet) {
playerPairings = new HashMap<Long, List<Player>>();
final Object[] playerArray = playersSet.toArray();
// Create the initial vector
final ICombinatoricsVector<Object> initialVector = Factory
.createVector(playerArray);
// Create a simple combination generator to generate 3-combinations of the initial
// vector
final Generator<Object> gen = Factory.createSimpleCombinationGenerator(
initialVector, 2);
// Print all possible combinations
long i = 0;
for (final ICombinatoricsVector<Object> combination : gen) {
System.out.println(combination);
Player playeraTemp = null;
Player playerbTemp = null;
final List<Object> cominationLst = combination.getVector();
playeraTemp = (Player) cominationLst.get(0);
playerbTemp = (Player) cominationLst.get(1);
assert (playeraTemp != null && playerbTemp != null && playeraTemp != playerbTemp);
final List<Player> newList = new ArrayList<Player>();
newList.add(playeraTemp);
newList.add(playerbTemp);
playerPairings.put(i, newList);
i++;
}
return playerPairings;
}
示例11: 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;
}
示例12: createAllMultiCharCombosExcludingOneTaskChar
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
public SortedSet<TaskCharSet> createAllMultiCharCombosExcludingOneTaskChar(TaskChar excluded, int maxSizeOfCombos) {
Collection<TaskChar> alphabet = taskCharArchive.getTaskChars();
Collection<TaskChar> otherChrs = new ArrayList<TaskChar>(alphabet);
if(excluded != null)
otherChrs.remove(excluded);
SortedSet<TaskCharSet> combos = new TreeSet<TaskCharSet>();
if (otherChrs.size() < 1) {
return combos;
}
// Create the initial vector
ICombinatoricsVector<TaskChar> initialVector = Factory.createVector(otherChrs);
Generator<TaskChar> gen = null;
Iterator<ICombinatoricsVector<TaskChar>> combosIterator = null;
if (maxSizeOfCombos < otherChrs.size()) {
for (int k=1; k <= maxSizeOfCombos; k++) {
// Create a simple combination generator to generate k-combinations of the initial vector
gen = Factory.createSimpleCombinationGenerator(initialVector, k);
combosIterator = gen.iterator();
while (combosIterator.hasNext()) {
combos.add(new TaskCharSet(combosIterator.next().getVector()));
}
}
} else {
Collection<TaskChar> auxComboVector = null;
// Create an instance of the subset generator
gen = Factory.createSubSetGenerator(initialVector);
combosIterator = gen.iterator();
while (combosIterator.hasNext()) {
auxComboVector = combosIterator.next().getVector();
if ( auxComboVector.size() > 0
&& auxComboVector.size() <= otherChrs.size()) {
combos.add(new TaskCharSet(auxComboVector));
}
}
}
return combos;
}
示例13: validateWithAllCombinations
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
/**
* Validates processor against many combinations built from available converters. For more details check
* https://github.com/dpaukov/combinatoricslib#5-subsets
*
* @param content
* content that should be converted
*/
public void validateWithAllCombinations(String content) {
ICombinatoricsVector<Converter> allConverters = Factory.createVector(CONVERTERS);
Generator<Converter> subSet = Factory.createSubSetGenerator(allConverters);
for (ICombinatoricsVector<Converter> subConverters : subSet) {
if (subConverters.getSize() != 0) {
Converter[] converters = subConverters.getVector().toArray(new Converter[subConverters.getSize()]);
validateWithSetsOfDecisions(converters, content);
}
}
}
示例14: validateWithSetsOfDecisions
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
private void validateWithSetsOfDecisions(Converter[] converters, String content) {
ICombinatoricsVector<Decision> allDecisions = Factory.createVector(DECISIONS);
Generator<Decision> subSet = Factory.createSubSetGenerator(allDecisions);
for (ICombinatoricsVector<Decision> subDecisions : subSet) {
if (subDecisions.getSize() != 0) {
Decision[] decisions = subDecisions.getVector().toArray(new Decision[subDecisions.getSize()]);
Execution[] executions = { new Execution(decisions, converters) };
validateProcessor(executions, content);
}
}
}
示例15: simpleOneCombinationTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleOneCombinationTest() {
// create array of initial items
List<String> array = new ArrayList<String>();
array.add("red");
// create combinatorics vector
ICombinatoricsVector<String> initialVector = Factory
.createVector(array);
// create simple combination generator to generate 1-combination
Generator<String> gen = Factory.createSimpleCombinationGenerator(
initialVector, 1);
// create iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// print the number of combinations
assertEquals(1, gen.getNumberOfGeneratedObjects());
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(1, list.size());
assertEquals("CombinatoricsVector=([red], size=1)", list.get(0)
.toString());
}