public class IntegerPermutationIter extends Object implements 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() |
Object |
next() |
int[] |
nextPermutation() |
void |
remove()
UNIMPLEMENTED.
|
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()
public int[] getNext()
public int[] getCurrent()
public String toString(int[] array)
array - public void remove()
remove in interface IteratorIterator.remove()public int[] nextPermutation()
nextPermutation in interface ArrayPermutationsIterpublic boolean hasNextPermutaions()
hasNextPermutaions in interface ArrayPermutationsIterCopyright © 2015. All Rights Reserved.