public final class IntCombinations extends Object
k numbers, which can be chosen from the set of n numbers (0,1,2,...,n). The
total number of such combinations is a binomial coefficient n!/(k!(n-k)!). Each returned array is sorted.
The iterator is implemented such that each next combination will be calculated only on the invocation of method
next().
Note: method next() returns the same reference on each invocation.
IntCombinationsWithPermutations,
Serialized Form| Constructor and Description |
|---|
IntCombinations(int n,
int k)
Constructs the iterator with the desired n and k
|
| Modifier and Type | Method and Description |
|---|---|
int[] |
current()
Returns the reference on the current iteration element.
|
boolean |
hasNext() |
int[] |
next() |
void |
remove() |
void |
reset()
Resets the iteration
|
List<int[]> |
toList()
Write all elements of this iterable to list
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waititerator, streamforEachRemainingforEach, spliteratorpublic IntCombinations(int n,
int k)
public boolean hasNext()
public void reset()
CombinatorialIteratorpublic int[] next()
public void remove()
UnsupportedOperationException - alwayspublic int[] current()
CombinatorialIteratorpublic final List<int[]> toList()
CombinatorialIteratortoList in interface CombinatorialIterator<int[]>Copyright © 2017. All rights reserved.