本文整理汇总了Java中org.paukov.combinatorics.Factory.createSubSetGenerator方法的典型用法代码示例。如果您正苦于以下问题:Java Factory.createSubSetGenerator方法的具体用法?Java Factory.createSubSetGenerator怎么用?Java Factory.createSubSetGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.paukov.combinatorics.Factory
的用法示例。
在下文中一共展示了Factory.createSubSetGenerator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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());
}
示例4: 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;
}
示例5: 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);
}
}
}
示例6: 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);
}
}
}
示例7: CompositionIterator
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
/**
* Constructor of the iterator
*
* @param generator The Composition generator
*/
CompositionIterator(CompositionGenerator generator) {
super();
_generator = generator;
ICombinatoricsVector<Integer> coreSet = Factory.createVector();
for (int i = 1; i < this._generator._initialValue; i++)
coreSet.addValue(i);
_subsetGenerator = Factory.createSubSetGenerator(coreSet);
_subsetIterator = _subsetGenerator.iterator();
}
示例8: simpleSubsetFroEachTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleSubsetFroEachTest() {
// create a combinatorics vector (A, B, C)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "A", "B", "C" });
// create a sub-set generator
Generator<String> gen = Factory.createSubSetGenerator(initialVector);
// verify the number of sunsets
assertEquals(8, gen.getNumberOfGeneratedObjects());
for( ICombinatoricsVector<String> combination : gen )
System.out.println("For Each: " + combination);
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(8, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
assertEquals("CombinatoricsVector=([A], size=1)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([B], size=1)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([A, B], size=2)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([C], size=1)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([A, C], size=2)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([B, C], size=2)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([A, B, C], size=3)", list.get(7)
.toString());
}
示例9: emptySubsetTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void emptySubsetTest() {
// create the empty combinatorics vector
ICombinatoricsVector<String> initialVector = Factory
.<String> createVector();
// create a sub-set generator
Generator<String> gen = Factory.createSubSetGenerator(initialVector);
// create an iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// verify the number of sunsets
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=([], size=0)", list.get(0).toString());
}
示例10: complexSubsetTest2
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void complexSubsetTest2() {
// create a combinatorics vector (A, A, A)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "A", "A", "A" });
// create a sub-set generator
Generator<String> gen = Factory.createSubSetGenerator(initialVector);
// create an iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(4, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
assertEquals("CombinatoricsVector=([A], size=1)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([A, A], size=2)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([A, A, A], size=3)", list.get(3)
.toString());
}
示例11: exactlyTwoElementsSubsetTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void exactlyTwoElementsSubsetTest() {
// create a combinatorics vector (a, b, c, d)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "a", "b", "c", "d" });
// create a sub-set generator
Generator<String> gen = Factory.createSubSetGenerator(initialVector);
List<ICombinatoricsVector<String>> list = gen.generateFilteredObjects(new IFilter<ICombinatoricsVector<String>>() {
@Override
public boolean accepted(long index, ICombinatoricsVector<String> value) {
return value.getSize() == 2;
}
});
assertEquals(6, list.size());
assertEquals("CombinatoricsVector=([a, b], size=2)", list.get(0)
.toString());
assertEquals("CombinatoricsVector=([a, c], size=2)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([b, c], size=2)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([a, d], size=2)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([b, d], size=2)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([c, d], size=2)", list.get(5)
.toString());
}
示例12: simpleSubsetTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void simpleSubsetTest() {
// create a combinatorics vector (A, B, C)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "A", "B", "C" });
// create a sub-set generator
Generator<String> gen = Factory.createSubSetGenerator(initialVector);
// create an iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// verify the number of sunsets
assertEquals(8, 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(8, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
assertEquals("CombinatoricsVector=([A], size=1)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([B], size=1)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([A, B], size=2)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([C], size=1)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([A, C], size=2)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([B, C], size=2)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([A, B, C], size=3)", list.get(7)
.toString());
}
示例13: complexSubsetTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void complexSubsetTest() {
// create a combinatorics vector (A, A, B, B, C)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "A", "A", "B", "B", "C" });
// create a sub-set generator
Generator<String> gen = Factory.createSubSetGenerator(initialVector);
// create an iterator
Iterator<ICombinatoricsVector<String>> itr = gen.iterator();
// go through the iterator
while (itr.hasNext()) {
ICombinatoricsVector<String> combination = itr.next();
System.out.println(combination);
}
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(18, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
assertEquals("CombinatoricsVector=([A], size=1)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([A, A], size=2)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([B], size=1)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([A, B], size=2)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([A, A, B], size=3)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([B, B], size=2)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([A, B, B], size=3)", list.get(7)
.toString());
assertEquals("CombinatoricsVector=([A, A, B, B], size=4)", list.get(8)
.toString());
assertEquals("CombinatoricsVector=([C], size=1)", list.get(9)
.toString());
assertEquals("CombinatoricsVector=([A, C], size=2)", list.get(10)
.toString());
assertEquals("CombinatoricsVector=([A, A, C], size=3)", list.get(11)
.toString());
assertEquals("CombinatoricsVector=([B, C], size=2)", list.get(12)
.toString());
assertEquals("CombinatoricsVector=([A, B, C], size=3)", list.get(13)
.toString());
assertEquals("CombinatoricsVector=([A, A, B, C], size=4)", list.get(14)
.toString());
assertEquals("CombinatoricsVector=([B, B, C], size=3)", list.get(15)
.toString());
assertEquals("CombinatoricsVector=([A, B, B, C], size=4)", list.get(16)
.toString());
assertEquals("CombinatoricsVector=([A, A, B, B, C], size=5)",
list.get(17).toString());
}
示例14: upToTwoElementsSubsetTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void upToTwoElementsSubsetTest() {
// create a combinatorics vector (a, b, c, d)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "a", "b", "c", "d" });
// create a sub-set generator
Generator<String> gen = Factory.createSubSetGenerator(initialVector);
List<ICombinatoricsVector<String>> list = gen.generateFilteredObjects(new IFilter<ICombinatoricsVector<String>>() {
@Override
public boolean accepted(long index, ICombinatoricsVector<String> value) {
return value.getSize() <= 2;
}
});
assertEquals(11, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0).toString());
assertEquals("CombinatoricsVector=([a], size=1)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([b], size=1)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([a, b], size=2)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([c], size=1)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([a, c], size=2)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([b, c], size=2)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([d], size=1)", list.get(7)
.toString());
assertEquals("CombinatoricsVector=([a, d], size=2)", list.get(8)
.toString());
assertEquals("CombinatoricsVector=([b, d], size=2)", list.get(9)
.toString());
assertEquals("CombinatoricsVector=([c, d], size=2)", list.get(10)
.toString());
}
示例15: treatAsDistinctSubsetTest
import org.paukov.combinatorics.Factory; //导入方法依赖的package包/类
@Test
public void treatAsDistinctSubsetTest() {
// create a combinatorics vector (a, b, c, d)
ICombinatoricsVector<String> initialVector = Factory
.createVector(new String[] { "a", "b", "b", "b" });
// create a sub-set generator and don't treat the identical elements as identical
Generator<String> gen = Factory.createSubSetGenerator(initialVector, false);
List<ICombinatoricsVector<String>> list = gen.generateAllObjects();
assertEquals(16, list.size());
assertEquals("CombinatoricsVector=([], size=0)", list.get(0)
.toString());
assertEquals("CombinatoricsVector=([a], size=1)", list.get(1)
.toString());
assertEquals("CombinatoricsVector=([b], size=1)", list.get(2)
.toString());
assertEquals("CombinatoricsVector=([a, b], size=2)", list.get(3)
.toString());
assertEquals("CombinatoricsVector=([b], size=1)", list.get(4)
.toString());
assertEquals("CombinatoricsVector=([a, b], size=2)", list.get(5)
.toString());
assertEquals("CombinatoricsVector=([b, b], size=2)", list.get(6)
.toString());
assertEquals("CombinatoricsVector=([a, b, b], size=3)", list.get(7)
.toString());
assertEquals("CombinatoricsVector=([b], size=1)", list.get(8)
.toString());
assertEquals("CombinatoricsVector=([a, b], size=2)", list.get(9)
.toString());
assertEquals("CombinatoricsVector=([b, b], size=2)", list.get(10)
.toString());
assertEquals("CombinatoricsVector=([a, b, b], size=3)", list.get(11)
.toString());
assertEquals("CombinatoricsVector=([b, b], size=2)", list.get(12)
.toString());
assertEquals("CombinatoricsVector=([a, b, b], size=3)", list.get(13)
.toString());
assertEquals("CombinatoricsVector=([b, b, b], size=3)", list.get(14)
.toString());
assertEquals("CombinatoricsVector=([a, b, b, b], size=4)", list.get(15)
.toString());
}