Format all C++ and Java code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 14:32:37 +07:00
parent 9f0290c0ec
commit bfffa1fff4
2169 changed files with 56441 additions and 64188 deletions

View File

@@ -11,18 +11,16 @@ namespace
double GetMinX(std::vector<m2::RectD> const & cells)
{
CHECK(!cells.empty(), ());
auto const minElementX =
std::min_element(std::cbegin(cells), std::cend(cells),
[](auto const & l, auto const & r) { return l.minX() < r.minX(); });
auto const minElementX = std::min_element(std::cbegin(cells), std::cend(cells),
[](auto const & l, auto const & r) { return l.minX() < r.minX(); });
return minElementX->minX();
}
double GetMinY(std::vector<m2::RectD> const & cells)
{
CHECK(!cells.empty(), ());
auto const minElementY =
std::min_element(std::cbegin(cells), std::cend(cells),
[](auto const & l, auto const & r) { return l.minY() < r.minY(); });
auto const minElementY = std::min_element(std::cbegin(cells), std::cend(cells),
[](auto const & l, auto const & r) { return l.minY() < r.minY(); });
return minElementY->minY();
}
} // namespace
@@ -70,10 +68,9 @@ void CellsMerger::CalcSum()
if (!Has(x, y))
continue;
auto & cell = Get(x, y);
cell.SetBottomLeft(
std::min({TryGet(x - 1, y).GetBottomLeft(), TryGet(x, y - 1).GetBottomLeft(),
TryGet(x - 1, y - 1).GetBottomLeft()}) +
1);
cell.SetBottomLeft(std::min({TryGet(x - 1, y).GetBottomLeft(), TryGet(x, y - 1).GetBottomLeft(),
TryGet(x - 1, y - 1).GetBottomLeft()}) +
1);
}
}
// Bottom right
@@ -84,10 +81,9 @@ void CellsMerger::CalcSum()
if (!Has(x, y))
continue;
auto & cell = Get(x, y);
cell.SetBottomRight(
std::min({TryGet(x + 1, y).GetBottomRight(), TryGet(x, y - 1).GetBottomRight(),
TryGet(x + 1, y - 1).GetBottomRight()}) +
1);
cell.SetBottomRight(std::min({TryGet(x + 1, y).GetBottomRight(), TryGet(x, y - 1).GetBottomRight(),
TryGet(x + 1, y - 1).GetBottomRight()}) +
1);
}
}
// Top left
@@ -98,9 +94,9 @@ void CellsMerger::CalcSum()
if (!Has(x, y))
continue;
auto & cell = Get(x, y);
cell.SetTopLeft(std::min({TryGet(x - 1, y).GetTopLeft(), TryGet(x, y + 1).GetTopLeft(),
TryGet(x - 1, y + 1).GetTopLeft()}) +
1);
cell.SetTopLeft(
std::min({TryGet(x - 1, y).GetTopLeft(), TryGet(x, y + 1).GetTopLeft(), TryGet(x - 1, y + 1).GetTopLeft()}) +
1);
}
}
// Top right
@@ -127,10 +123,12 @@ CellWrapper & CellsMerger::Get(m2::PointI const & xy)
return it->second;
}
CellWrapper & CellsMerger::Get(int32_t x, int32_t y) { return Get({x, y}); }
CellWrapper & CellsMerger::Get(int32_t x, int32_t y)
{
return Get({x, y});
}
CellWrapper const & CellsMerger::TryGet(int32_t x, int32_t y,
CellWrapper const & defaultValue) const
CellWrapper const & CellsMerger::TryGet(int32_t x, int32_t y, CellWrapper const & defaultValue) const
{
auto const it = m_matrix.find({x, y});
return it == std::cend(m_matrix) ? defaultValue : it->second;
@@ -144,16 +142,12 @@ m2::PointI CellsMerger::FindBigSquare(m2::PointI const & xy, m2::PointI const &
{
auto const xMinMax = std::minmax(currXy.x, xy.x);
for (int32_t x = xMinMax.first; x <= xMinMax.second; ++x)
{
if (!Has({x, currXy.y}))
return prevXy;
}
auto const yMinMax = std::minmax(currXy.y, xy.y);
for (int32_t y = yMinMax.first; y <= yMinMax.second; ++y)
{
if (!Has({currXy.x, y}))
return prevXy;
}
prevXy = currXy;
currXy += direction;
}
@@ -163,16 +157,14 @@ std::optional<m2::PointI> CellsMerger::FindDirection(m2::PointI const & startXy)
{
std::array<std::pair<size_t, m2::PointI>, 4> directionsWithWeight;
std::array<m2::PointI, 4> const directions{{{1, 1}, {-1, 1}, {1, -1}, {-1, -1}}};
base::Transform(directions, std::begin(directionsWithWeight),
[&](auto const & direction) {
return std::make_pair(
TryGet(startXy.x + direction.x, startXy.y).GetSum() +
TryGet(startXy.x, startXy.y + direction.y).GetSum() +
TryGet(startXy.x + direction.x, startXy.y + direction.y).GetSum(),
direction);
});
auto const direction =
std::max_element(std::cbegin(directionsWithWeight), std::cend(directionsWithWeight))->second;
base::Transform(directions, std::begin(directionsWithWeight), [&](auto const & direction)
{
return std::make_pair(TryGet(startXy.x + direction.x, startXy.y).GetSum() +
TryGet(startXy.x, startXy.y + direction.y).GetSum() +
TryGet(startXy.x + direction.x, startXy.y + direction.y).GetSum(),
direction);
});
auto const direction = std::max_element(std::cbegin(directionsWithWeight), std::cend(directionsWithWeight))->second;
return Has(startXy + direction) ? direction : std::optional<m2::PointI>{};
}
@@ -181,15 +173,19 @@ void CellsMerger::Remove(m2::PointI const & minXy, m2::PointI const & maxXy)
auto const xMinMax = std::minmax(minXy.x, maxXy.x);
auto const yMinMax = std::minmax(minXy.y, maxXy.y);
for (int32_t x = xMinMax.first; x <= xMinMax.second; ++x)
{
for (int32_t y = yMinMax.first; y <= yMinMax.second; ++y)
m_matrix.erase({x, y});
}
}
bool CellsMerger::Has(int32_t x, int32_t y) const { return m_matrix.count({x, y}) != 0; }
bool CellsMerger::Has(int32_t x, int32_t y) const
{
return m_matrix.count({x, y}) != 0;
}
bool CellsMerger::Has(const m2::PointI & xy) const { return Has(xy.x, xy.y); }
bool CellsMerger::Has(m2::PointI const & xy) const
{
return Has(xy.x, xy.y);
}
std::optional<m2::PointI> CellsMerger::FindMax() const
{