(a)
for(i = 0, fi_r = fi_p; i < file_count; i++, fi_r++) {
  for(j = 0; j < fi_r->data_blocks; j++) {
    block_indices_p[get_ran(ran_array_p, &n)] = i;
  } 
} 

(b)
for each file
   for eack block in this file
      reset block_indices_p[random index] to the index of this file.
   end
end

Example 1: The encryption program. The nested loops in Example 1(a) can be read as Example 1(b).

Back to Article
Copyright © 1999, Dr. Dobb's Journal