public ArrayListOfIntsWritable nextPermutation() {
if(combEnd==NUM_BLOCKS){
throw new RuntimeException("Too many calls! All permutations done!");
}
System.err.println(combStart+","+combEnd);
ArrayListOfIntsWritable perm = new ArrayListOfIntsWritable();
addAll(perm, blocks[combStart].getArray());
addAll(perm, blocks[combEnd].getArray());
// if(combStart==(BLOCK_SIZE-1) ||combEnd==(BLOCK_SIZE-1)){
// keyLen = 25;
// }else{
// keyLen = 26;
// }
ArrayList<Integer> rest = new ArrayList<Integer>();
for(int i=0;i<NUM_BLOCKS;i++){
if(i!=combStart && i!=combEnd){
rest.add(i);
}
}
Collections.shuffle(rest);
for(int nextBlock : rest){
addAll(perm, blocks[nextBlock].getArray());
}
if(perm.size()!=length){
throw new RuntimeException("Number of elements not correct!");
}
if(combEnd==(NUM_BLOCKS-1)){
combStart++;
combEnd = combStart+1;