Permute Sequence Of Indices

Synopsis

Permute a sequence of indices.

Results

Output:

1 0 4 3 2

After shuffle
4 1 0 2 3

Code

C++

#include <itkImageRandomNonRepeatingConstIteratorWithIndex.h>

int
main(int, char *[])
{
  itk::RandomPermutation rp(5);

  std::cout << std::endl;

  for (unsigned int i = 0; i < 5; i++)
  {
    std::cout << rp[i] << " ";
  }
  std::cout << std::endl << std::endl;

  rp.Shuffle();
  std::cout << "After shuffle" << std::endl;
  for (unsigned int i = 0; i < 5; i++)
  {
    std::cout << rp[i] << " ";
  }
  std::cout << std::endl;


  return EXIT_SUCCESS;
}

Classes demonstrated