Example #1
0
        private int[] shuffled; // shuffled sequence

        // The constructor of class Permutation creates a shuffled
        // sequence of the integers 0 ... (size-1).
        internal Permutation(int size, F5Random random)
        {
            int i, randomIndex;

            this.shuffled = new int[size];

            // To create the shuffled sequence, we initialise an array
            // with the integers 0 ... (size-1).
            for (i = 0; i < size; i++)
            {
                // initialise with "size" integers
                this.shuffled[i] = i;
            }
            int maxRandom = size; // set number of entries to shuffle

            for (i = 0; i < size; i++)
            {
                // shuffle entries
                randomIndex = random.GetNextValue(maxRandom--);
                Swap(ref this.shuffled[maxRandom], ref this.shuffled[randomIndex]);
            }
        }
        private int[] shuffled; // shuffled sequence

        #endregion Fields

        #region Constructors

        // The constructor of class Permutation creates a shuffled
        // sequence of the integers 0 ... (size-1).
        internal Permutation(int size, F5Random random)
        {
            int i, randomIndex;
            this.shuffled = new int[size];

            // To create the shuffled sequence, we initialise an array
            // with the integers 0 ... (size-1).
            for (i = 0; i < size; i++)
            {
                // initialise with "size" integers
                this.shuffled[i] = i;
            }
            int maxRandom = size; // set number of entries to shuffle
            for (i = 0; i < size; i++)
            {
                // shuffle entries
                randomIndex = random.GetNextValue(maxRandom--);
                Swap(ref this.shuffled[maxRandom], ref this.shuffled[randomIndex]);
            }
        }