Exemplo n.º 1
0
            public bool MoveNext()
            {
                idx += 1;

                if (_useSubGrid)
                {
                    //var row = grid.getRow(idx);
                    var col = grid.getCol(idx);
                    if (col < _col0)
                    {
                        idx += _col0 - col;
                    }
                    if (col > _col1)
                    {
                        idx += grid.numCols - col;
                    }
                    if (idx > _lastIndex)
                    {
                        return(false);
                    }
                }

                if (idx >= grid.numCells)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
Exemplo n.º 2
0
            /// <summary> Initializes a CellEnumerator that enumerates cells within
            /// the rectangular subgrid defined by cell indices at two opposite
            /// corners of the subgrid. </summary>
            public CellEnumerator(LeapGrid grid, int subGridBegin, int subGridEnd) :
                this(grid)
            {
                int idx0 = subGridBegin, idx1 = subGridEnd;
                int row0 = grid.getRow(idx0), row1 = grid.getRow(idx1);
                if (row0 > row1)
                {
                    Utils.Swap(ref row0, ref row1);
                }
                int col0 = grid.getCol(idx0), col1 = grid.getCol(idx1);
                if (col0 > col1)
                {
                    Utils.Swap(ref col0, ref col1);
                }
                _col0 = col0; _col1 = col1;

                _lastIndex  = Mathf.Max(subGridBegin, subGridEnd);
                idx         = grid.getIndex(row0, col0) - 1;
                _useSubGrid = true;
            }