mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #325, added async. sort (kind of experimental feature to see performance impact)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user