Replaced hand-crafted reverse algorithm with std::reverse

This commit is contained in:
llocram 2020-08-28 14:09:16 +02:00
parent ed970fe6f6
commit 1a2c5de357
2 changed files with 13 additions and 21 deletions

View File

@ -508,20 +508,11 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContai
template <class T>
QVector<T> VLayoutPiece::Map(QVector<T> points) const
{
for (int i = 0; i < points.size(); ++i)
{
points[i] = d->matrix.map(points.at(i));
}
std::transform(points.begin(), points.end(), points.begin(),
[this](const auto &point) { return d->matrix.map(point); });
if (d->mirror)
{
QList<T> list = ConvertToList(points);
for (int k=0, s=list.size(), max=(s/2); k<max; k++)
{
SwapItemsAt(list, k, s-(1+k));
}
points = ConvertToVector(list);
std::reverse(points.begin(), points.end());
}
return points;
}

View File

@ -148,15 +148,16 @@ inline QVector<T> ConvertToVector(const QSet<T> &container)
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
inline void SwapItemsAt(T &container, int i, int j)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
container.swapItemsAt(i, j);
#else
container.swap(i, j);
#endif
}
// NOTE: Delete if not necessary anymore
//template <typename T>
//inline void SwapItemsAt(T &container, int i, int j)
//{
//#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
// container.swapItemsAt(i, j);
//#else
// container.swap(i, j);
//#endif
//}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>