From 053c248f060ace08cc7db2cf07b14cc91f27f11c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 16 Sep 2014 13:41:37 +0200 Subject: [PATCH] refs #325, added async. sort (kind of experimental feature to see performance impact) --- src/blackmisc/sequence.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/blackmisc/sequence.h b/src/blackmisc/sequence.h index e196d1432..9bf67fd2f 100644 --- a/src/blackmisc/sequence.h +++ b/src/blackmisc/sequence.h @@ -20,6 +20,7 @@ #include #include #include +#include namespace BlackMisc { @@ -465,6 +466,28 @@ namespace BlackMisc return result; } + /*! + * \brief Return a copy as derived container sorted by a given comparator predicate. + */ + template + 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 + QFuture sortedAsync(Predicate p) const + { + QFuture f = QtConcurrent::run(this, &CSequence::sortedDerived, p); + return f; + } + /*! * \brief Return a copy sorted by some particular key(s). * \param key1 A pointer to a member function of T.