DATATYPE - Element type to be combinedpublic class CombinationGenerator<DATATYPE> extends Object implements IIterableIterator<ICommonsList<DATATYPE>>
| Constructor and Description |
|---|
CombinationGenerator(ICommonsList<DATATYPE> aElements,
int nSlotCount)
Ctor
|
| Modifier and Type | Method and Description |
|---|---|
static <DATATYPE> void |
addAllPermutations(ICommonsList<DATATYPE> aInput,
int nSlotCount,
Collection<ICommonsList<DATATYPE>> aResultList)
Fill a list with all permutations of the input elements.
|
static <DATATYPE> ICommonsList<ICommonsList<DATATYPE>> |
getAllPermutations(ICommonsList<DATATYPE> aInput,
int nSlotCount)
Get a list of all permutations of the input elements.
|
BigInteger |
getCombinationsLeft() |
BigInteger |
getTotalCombinations() |
boolean |
hasNext() |
ICommonsList<DATATYPE> |
next()
Generate next combination (algorithm from Rosen p. 286)
|
void |
reset()
Reset the generator
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waititerator, withFilter, withMappercontainsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstMapped, findFirstMapped, forEach, forEachBreakable, forEachByIndex, getCount, getCountforEach, spliteratorforEachRemaining, removepublic CombinationGenerator(@Nonnull @Nonempty ICommonsList<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 final void reset()
@Nonnull public BigInteger getCombinationsLeft()
public boolean hasNext()
hasNext in interface Iterator<ICommonsList<DATATYPE>>@Nonnull public BigInteger getTotalCombinations()
@Nonnull @ReturnsMutableCopy public ICommonsList<DATATYPE> next()
next in interface Iterator<ICommonsList<DATATYPE>>@Nonnull public static <DATATYPE> ICommonsList<ICommonsList<DATATYPE>> getAllPermutations(@Nonnull @Nonempty ICommonsList<DATATYPE> aInput, @Nonnegative int nSlotCount)
DATATYPE - Element type to be combinedaInput - Input list.nSlotCount - Slot count.public static <DATATYPE> void addAllPermutations(@Nonnull @Nonempty ICommonsList<DATATYPE> aInput, @Nonnegative int nSlotCount, @Nonnull Collection<ICommonsList<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–2017 Philip Helger. All rights reserved.