16 private int[] p_ =
null;
18 void swap(
int i,
int j) {
19 int t=p_[i]; p_[i]=p_[j]; p_[j]=t;
21 void reverse(
int i,
int j) {
42 @Override
public int[]
next() {
43 int[] p =
new int[p_.length];
45 for (
int j=0;j<p_.length;++j)
55 while (p_[i]>=p_[--j]) {}
72 @Override
public void remove() {
73 throw new UnsupportedOperationException();
77 public static void main(String[] args) {
79 int n=args.length>0 ? Integer.parseInt(args[0]) : 3;
Iterator over all permutations of length n.
static void main(String[] args)
demonstration and test
PermutationIterator(int n)
create new iterator