ImbaCow / OOP

Repo for object oriented programming
0 stars 0 forks source link

Замечания по Fill #9

Open alexey-malov opened 5 years ago

alexey-malov commented 5 years ago
alexey-malov commented 5 years ago
alexey-malov commented 5 years ago
    std::vector<std::vector<char>> m_fields;
alexey-malov commented 5 years ago
    if (CanFill({ current.x - 1, current.y }))
    {
        coordsStack.push({ current.x - 1, current.y });
    }
    if (CanFill({ current.x + 1, current.y }))
    {
        coordsStack.push({ current.x + 1, current.y });
    }
    if (CanFill({ current.x, current.y - 1 }))
    {
        coordsStack.push({ current.x, current.y - 1 });
    }
    if (CanFill({ current.x, current.y + 1 }))
    {
        coordsStack.push({ current.x, current.y + 1 });
    }
alexey-malov commented 5 years ago
    while (m_fields.size() <= paintCoords.y)
    {
        m_fields.push_back({});
    }

лучше сделать if () m_field.resize(paintCoords.y);

    while (m_fields[paintCoords.y].size() <= paintCoords.x)
    {
        m_fields[paintCoords.y].push_back(EMPTY_CHAR);
    }