code: public static <R> ImmutableGrid<R> copyOfDeriveCounts(Iterable<? extends Cell<R>> cells) {
          if (cells == null) {
              throw new IllegalArgumentException("Cells must not be null");
          }
          if (!cells.iterator().hasNext()) {
              return new EmptyGrid<R>();
          }
          int rowCount = 0;
          int columnCount = 0;
          for (Cell<R> cell : cells) {
              rowCount = Math.max(rowCount, cell.getRow());
              columnCount = Math.max(columnCount, cell.getColumn());
          }
          return new SparseImmutableGrid<R>(rowCount + 1, columnCount + 1, cells);
      }
docs: Obtains an immutable grid by copying a set of cells, deriving the row and column count.
  <p>
  The row and column counts are calculated as the maximum row and column specified.
  
  @param <R> the type of the value
  @param cells  the cells to copy, not null
  @return the immutable grid, not null
  @throws IndexOutOfBoundsException if either index is less than zero