Ejemplo n.º 1
0
 public T this[ILoc loc]
 {
     get
     {
         var(row, col) = loc.ToRowCol();
         return(_cells[row, col]);
     }
     set
     {
         var(row, col)    = loc.ToRowCol();
         _cells[row, col] = value;
     }
 }
Ejemplo n.º 2
0
        public Grid <(ILoc origLoc, T origValue)> SubGrid(ILoc startLoc, int rowLength, int colLength)
        {
            var(startRow, startCol) = startLoc.ToRowCol();

            (ILoc originLoc, T origValue) MoveCell(ILoc loc)
            {
                var(r, c) = loc.ToRowCol();
                var l = new Loc(startRow + r, startCol + c);

                return(l, this[l]);
            }

            if (startRow < 0)
            {
                startRow = 0;
            }
            if (startCol < 0)
            {
                startCol = 0;
            }
            if (startRow + rowLength > RowCount)
            {
                rowLength = RowCount - startRow;
            }
            if (startCol + colLength > ColCount)
            {
                colLength = ColCount - startCol;
            }
            var ret = new Grid <(ILoc, T)>(rowLength, colLength);

            Transfer(MoveCell, ret);
            return(ret);
        }