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.