summaryrefslogtreecommitdiffstats
path: root/src/concurrent/qtconcurrentmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/concurrent/qtconcurrentmap.h')
-rw-r--r--src/concurrent/qtconcurrentmap.h132
1 files changed, 132 insertions, 0 deletions
diff --git a/src/concurrent/qtconcurrentmap.h b/src/concurrent/qtconcurrentmap.h
index 151f03cf56..a1e7cf1044 100644
--- a/src/concurrent/qtconcurrentmap.h
+++ b/src/concurrent/qtconcurrentmap.h
@@ -83,6 +83,21 @@ QFuture<ResultType> mappedReduced(const Sequence &sequence,
options);
}
+template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
+ typename InitialValueType,
+ std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
+QFuture<ResultType> mappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce,
+ InitialValueType &&initialValue,
+ ReduceOptions options = ReduceOptions(UnorderedReduce
+ | SequentialReduce))
+{
+ return startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType,
+ ResultType>(sequence, QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ ResultType(std::forward<InitialValueType>(initialValue)),
+ options);
+}
+
template <typename Sequence, typename MapFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(const Sequence &sequence,
MapFunctor map,
@@ -96,6 +111,22 @@ QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedR
options);
}
+template <typename Sequence, typename MapFunctor, typename ReduceFunctor,
+ typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
+ typename InitialValueType,
+ std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
+QFuture<ResultType> mappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce,
+ InitialValueType &&initialValue,
+ ReduceOptions options = ReduceOptions(UnorderedReduce
+ | SequentialReduce))
+{
+ return startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType,
+ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>(
+ sequence, QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ ResultType(std::forward<InitialValueType>(initialValue)), options);
+}
+
// mappedReduced() for iterators
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
QFuture<ResultType> mappedReduced(Iterator begin,
@@ -111,6 +142,21 @@ QFuture<ResultType> mappedReduced(Iterator begin,
options);
}
+template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
+ typename InitialValueType,
+ std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
+QFuture<ResultType> mappedReduced(Iterator begin, Iterator end, MapFunctor map,
+ ReduceFunctor reduce, InitialValueType &&initialValue,
+ ReduceOptions options = ReduceOptions(UnorderedReduce
+ | SequentialReduce))
+{
+ return startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType,
+ ResultType>(begin, end, QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ ResultType(std::forward<InitialValueType>(initialValue)),
+ options);
+}
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(Iterator begin,
Iterator end,
@@ -125,6 +171,22 @@ QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedR
options);
}
+template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
+ typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
+ typename InitialValueType,
+ std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
+QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(
+ Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce,
+ InitialValueType &&initialValue,
+ ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
+{
+ return startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType,
+ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>(
+ begin, end, QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ ResultType(std::forward<InitialValueType>(initialValue)), options);
+}
+
// mapped() for sequences
template <typename Sequence, typename MapFunctor>
QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> mapped(const Sequence &sequence, MapFunctor map)
@@ -168,6 +230,22 @@ ResultType blockingMappedReduced(const Sequence &sequence,
.startBlocking();
}
+template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
+ typename InitialValueType,
+ std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
+ResultType blockingMappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce,
+ InitialValueType &&initialValue,
+ ReduceOptions options = ReduceOptions(UnorderedReduce
+ | SequentialReduce))
+{
+ return QtConcurrent::startMappedReduced<
+ typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType>(
+ sequence, QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ ResultType(std::forward<InitialValueType>(initialValue)), options)
+ .startBlocking();
+}
+
template <typename MapFunctor, typename ReduceFunctor, typename Sequence>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(const Sequence &sequence,
MapFunctor map,
@@ -182,6 +260,24 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedRe
.startBlocking();
}
+template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
+ typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
+ typename InitialValueType,
+ std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
+typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
+ const Sequence &sequence, MapFunctor map, ReduceFunctor reduce,
+ InitialValueType &&initialValue,
+ ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
+{
+ return QtConcurrent::startMappedReduced<
+ typename QtPrivate::MapResultType<void, MapFunctor>::ResultType,
+ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>(
+ sequence, QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ ResultType(std::forward<InitialValueType>(initialValue)), options)
+ .startBlocking();
+}
+
// blockingMappedReduced() for iterator ranges
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
ResultType blockingMappedReduced(Iterator begin,
@@ -198,6 +294,23 @@ ResultType blockingMappedReduced(Iterator begin,
.startBlocking();
}
+template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
+ typename InitialValueType,
+ std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
+ResultType blockingMappedReduced(Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce,
+ InitialValueType &&initialValue,
+ QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(
+ QtConcurrent::UnorderedReduce
+ | QtConcurrent::SequentialReduce))
+{
+ return QtConcurrent::startMappedReduced<
+ typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType>(
+ begin, end, QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ ResultType(std::forward<InitialValueType>(initialValue)), options)
+ .startBlocking();
+}
+
template <typename Iterator, typename MapFunctor, typename ReduceFunctor>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(Iterator begin,
Iterator end,
@@ -213,6 +326,25 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedRe
.startBlocking();
}
+template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
+ typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
+ typename InitialValueType,
+ std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
+typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
+ Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce,
+ InitialValueType &&initialValue,
+ QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(
+ QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
+{
+ return QtConcurrent::startMappedReduced<
+ typename QtPrivate::MapResultType<void, MapFunctor>::ResultType,
+ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>(
+ begin, end, QtPrivate::createFunctionWrapper(map),
+ QtPrivate::createFunctionWrapper(reduce),
+ ResultType(std::forward<InitialValueType>(initialValue)), options)
+ .startBlocking();
+}
+
// mapped() for sequences with a different putput sequence type.
template <typename OutputSequence, typename InputSequence, typename MapFunctor>
OutputSequence blockingMapped(const InputSequence &sequence, MapFunctor map)