public class IntegerPermutationIter extends java.lang.Object implements java.util.Iterator, ArrayPermutationsIter
Constructor and Description |
---|
IntegerPermutationIter(int N)
Creates an array of size N with elements 1,2,...,n-1 Useful for
describing regular permutations.
|
IntegerPermutationIter(int[] array)
Uses a predefined array (sorted), for example: [3,1,1,2,1]-->[1,1,1,2,3];
note that there are much less than 5! premutations here, because of the
repetitive 1s.
|
Modifier and Type | Method and Description |
---|---|
int[] |
getCurrent() |
int[] |
getNext()
Facade.
|
boolean |
hasNext()
Efficiency: O(N) implementation, try to take the next!
|
boolean |
hasNextPermutaions() |
java.lang.Object |
next() |
int[] |
nextPermutation() |
void |
remove()
UNIMPLEMENTED.
|
java.lang.String |
toString(int[] array)
Utility method to convert the array into a string examples: [] [0]
[0,1][1,0]
|
public IntegerPermutationIter(int N)
N
- public IntegerPermutationIter(int[] array)
array
- creates a copy of it (so sort / later changes will not
matter)public boolean hasNext()
hasNext
in interface java.util.Iterator
public java.lang.Object next()
next
in interface java.util.Iterator
public int[] getNext()
public int[] getCurrent()
public java.lang.String toString(int[] array)
array
- public void remove()
remove
in interface java.util.Iterator
Iterator.remove()
public int[] nextPermutation()
nextPermutation
in interface ArrayPermutationsIter
public boolean hasNextPermutaions()
hasNextPermutaions
in interface ArrayPermutationsIter