|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcommon.PermutationIterator
public class PermutationIterator
An iterator for iterating over all the ways to make an ordered list of k distinct elements from a set of size n. When k = n, this means iterating over all the permutations of a set of size n. We assume the set of size n can be ordered in some way, so that its elements are numbered 0, 1, ..., n-1. A permutation is represented as an integer array of length k containing numbers in {0, 1, ..., n-1}. Each number occurs at most once in the permutation.
| Constructor Summary | |
|---|---|
PermutationIterator(int n,
int k)
Creates a new PermutationIterator for iterating over permutations of k elements from a set of size n. |
|
| Method Summary | |
|---|---|
boolean |
hasNext()
Returns true if there is a permutation that hasn't been returned yet. |
static void |
main(java.lang.String[] args)
|
java.lang.Object |
next()
Returns the next permutation. |
void |
remove()
Not supported. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PermutationIterator(int n,
int k)
| Method Detail |
|---|
public boolean hasNext()
hasNext in interface java.util.Iteratorpublic java.lang.Object next()
next.
next in interface java.util.Iteratorpublic void remove()
remove in interface java.util.Iteratorpublic static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||