public static void main(String[] args){
int SIZE = 1000;
PermutationByBit p = new PermutationByBit(SIZE);
for(int k=0;k<100;k++){
ArrayListOfIntsWritable a = p.nextPermutation();
//make sure the permutation is not out of bounds
for(int i=0;i<SIZE;i++){
assertTrue(i+"-->"+a.get(i),a.get(i)<SIZE && a.get(i)>=0);
}
//make sure each position is included in the permutation exactly once
int[] positions = new int[SIZE];
for(int i=0;i<SIZE;i++){
if(positions[a.get(i)]==1){
fail("Same position included twice: "+a.get(i));
}
positions[a.get(i)]=1;
}
for(int i=0;i<SIZE;i++){
if(positions[i]==0){
// System.out.println(java.util.Arrays.binarySearch(positions, i));
fail("Position not included: "+i);