DATATYPE - Element type to be combinedpublic class CombinationGenerator<DATATYPE> extends Object implements IIterableIterator<List<DATATYPE>>
| Constructor and Description |
|---|
CombinationGenerator(List<DATATYPE> aElements,
int nSlotCount)
Ctor
|
| Modifier and Type | Method and Description |
|---|---|
static <DATATYPE> void |
addAllPermutations(List<DATATYPE> aInput,
int nSlotCount,
Collection<List<DATATYPE>> aResultList)
Fill a list with all permutations of the input elements.
|
static <DATATYPE> List<List<DATATYPE>> |
getAllPermutations(List<DATATYPE> aInput,
int nSlotCount)
Get a list of all permutations of the input elements.
|
BigInteger |
getCombinationsLeft() |
BigInteger |
getTotalCombinations() |
boolean |
hasNext() |
Iterator<List<DATATYPE>> |
iterator() |
List<DATATYPE> |
next()
Generate next combination (algorithm from Rosen p. 286)
|
void |
remove() |
void |
reset()
Reset the generator
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorforEachRemainingpublic CombinationGenerator(@Nonnull @Nonempty List<DATATYPE> aElements, @Nonnegative int nSlotCount)
aElements - the elements to fill into the slots for creating all combinations
(must not be empty!)nSlotCount - the number of slots to use (must not be greater than the element
count!)public void reset()
@Nonnull public BigInteger getCombinationsLeft()
public boolean hasNext()
@Nonnull public BigInteger getTotalCombinations()
@Nonnull @ReturnsMutableCopy public List<DATATYPE> next()
@UnsupportedOperation public void remove()
@Nonnull public static <DATATYPE> List<List<DATATYPE>> getAllPermutations(@Nonnull @Nonempty List<DATATYPE> aInput, @Nonnegative int nSlotCount)
DATATYPE - Element type to be combinedaInput - Input list.nSlotCount - Slot count.public static <DATATYPE> void addAllPermutations(@Nonnull @Nonempty List<DATATYPE> aInput, @Nonnegative int nSlotCount, @Nonnull Collection<List<DATATYPE>> aResultList)
DATATYPE - Element type to be combinedaInput - Input list.nSlotCount - Slot count.aResultList - The list to be filled with all permutations. Beware: this list may
be quite large and may contain duplicates if the input list contains
duplicate elements! Note: this list is not cleared before fillingCopyright © 2014–2015 Philip Helger. All rights reserved.