Fix error in Reverse function.

This commit is contained in:
Roman Telezhynskyi 2020-07-13 18:23:15 +03:00
parent 9389cb546c
commit dc14f164be

View File

@ -31,6 +31,7 @@
#include <QtGlobal>
#include <QStringList>
#include <QSet>
#include <QVector>
class QPointF;
@ -183,14 +184,13 @@ inline void Move(T &vector, int from, int to)
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
T Reverse(const T &container)
QVector<T> Reverse(const QVector<T> &container)
{
if (container.isEmpty())
{
return container;
}
T reversed;
reversed.reserve(container.size());
QVector<T> reversed(container.size());
qint32 j = 0;
for (qint32 i = container.size() - 1; i >= 0; --i)
{
@ -200,6 +200,20 @@ T Reverse(const T &container)
return reversed;
}
template <typename T, template <typename> class C>
//---------------------------------------------------------------------------------------------------------------------
C<T> Reverse(const C<T> &container)
{
return ConvertToList(Reverse(ConvertToVector(container)));
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T, typename std::enable_if<std::is_same<T, QStringList>::value, T>::type* = nullptr>
T Reverse(const T &container)
{
return Reverse<QString, QList>(container);
}
//---------------------------------------------------------------------------------------------------------------------
template <typename Cont, typename Input>
inline void AppendTo(Cont &container, const Input &input)