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() == false) {
            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);
    }