protected override void formTrace()
    {
        for (int i = 0; i < elements; i++)
            trace[i] = new IndexPair(i / rows, i % rows);

        return;
    }
    protected override void formTrace()
    {
        count = elements;
        i = j = 0;

        bool wereSteppingDown;
        bool wereSteppingRight;
        int level = 0;

        do
        {
            wereSteppingDown = false;
            wereSteppingRight = false;

            // Stepping right at upper border
            if (j < columns - level - 1) wereSteppingRight = true;
            while (j < columns - level - 1)
            {
                trace[elements - (count--)] = new IndexPair(i, j);
                j++;
            }

            // Stepping down at rightmost border.
            if (i < rows - level - 1) wereSteppingDown = true;
            while (i < rows - level - 1)
            {
                trace[elements - (count--)] = new IndexPair(i, j);
                i++;
            }

            // Stepping left at downmost border.
            if (wereSteppingDown && wereSteppingRight)
            {
                while (j > level)
                {
                    trace[elements - (count--)] = new IndexPair(i, j);
                    j--;
                }
            }
            // Stepping up at leftmost border.
            if (wereSteppingDown && wereSteppingRight)
            {
                while (i > level + 1)
                {
                    trace[elements - (count--)] = new IndexPair(i, j);
                    i--;
                }
            }

            level++;    // increase indent level
        } while (count > 1);

        if(count>0) trace[elements - 1] = new IndexPair(i, j);  // предусмотрено для нулевых матриц
        return;
    }
        /// <summary>
        /// Обеспечивает двусторонний проход по массиву стандартной построчной развертки
        /// путем пошаговой перестановки текущего элемента со случайным и 
        /// центрально-симметрично текущему со случайным.
        /// </summary>
        protected override void formTrace()
        {
            // ------ первоначальная развертка

            RowByRowWinder temp = new RowByRowWinder(this.rows, this.columns);
            IndexPair t = new IndexPair();
            this.trace = temp.trace;

            // ------ проход по циклу с обменами

            for (int i = 0; i < trace.Length; i++)
            {
                int switchInd = gen.Next(trace.Length);
                int switchInd2 = gen.Next(trace.Length);

                t = trace[i];
                trace[i] = trace[switchInd];
                trace[switchInd] = t;

                t = trace[trace.Length - i - 1];
                trace[trace.Length - i - 1] = trace[switchInd2];
                trace[switchInd2] = t;
            }
        }
    protected override void formTrace()
    {
        for (int k = 0; k < this.elements; k++)
        {
            trace[k] = new IndexPair(i, j);
            analyzeCellType();
            analyzeDirection();
            performStep();
        }

        i = j = 0;
    }
Beispiel #5
0
 /// <summary>
 /// Overloaded. Gets or sets the numeric value using the pair of indexes.
 /// Performs the bounds checking.
 ///
 /// Does NOT perform the element copying.
 /// All changes made to the reference type element got or set will be reflected on the matrix.
 /// Use <see cref="MatrixElementCopyAdapter"/> if such behaviour is unwanted.
 /// </summary>
 /// <param name="indexPair">The IndexPair object containing a pair of indexes.</param>
 /// <returns>The double value at specified point.</returns>
 public Numeric <T, C> this[IndexPair indexPair]
 {
     get { return(this[indexPair.row, indexPair.column]); }
     set { this[indexPair.row, indexPair.column] = value; }
 }