refs #325, added async. sort (kind of experimental feature to see performance impact)

This commit is contained in:
Klaus Basan
2014-09-16 13:41:37 +02:00
parent 5d6713032f
commit 053c248f06

View File

@@ -20,6 +20,7 @@
#include <iterator>
#include <utility>
#include <initializer_list>
#include <QtConcurrent/QtConcurrent>
namespace BlackMisc
{
@@ -465,6 +466,28 @@ namespace BlackMisc
return result;
}
/*!
* \brief Return a copy as derived container sorted by a given comparator predicate.
*/
template <class TargetContainer, class Predicate>
TargetContainer sortedDerived(Predicate p) const
{
CSequence result = *this;
result.sort(p);
return result;
}
/*!
* \brief Return a copy as derived container sorted by a given comparator predicate.
* \remarks Sorts in background.
*/
template <class TargetContainer, class Predicate>
QFuture<TargetContainer> sortedAsync(Predicate p) const
{
QFuture<TargetContainer> f = QtConcurrent::run(this, &CSequence::sortedDerived<TargetContainer, Predicate>, p);
return f;
}
/*!
* \brief Return a copy sorted by some particular key(s).
* \param key1 A pointer to a member function of T.