4#ifndef QTCONCURRENT_MAP_H
5#define QTCONCURRENT_MAP_H
8#pragma qt_class(QtConcurrentMap)
11#include <QtConcurrent/qtconcurrent_global.h>
13#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
15#include <QtConcurrent/qtconcurrentmapkernel.h>
16#include <QtConcurrent/qtconcurrentreducekernel.h>
17#include <QtConcurrent/qtconcurrentfunctionwrappers.h>
26template <
typename Sequence,
typename MapFunctor>
29 return startMap(
pool, sequence.begin(), sequence.end(), std::forward<MapFunctor>(
map));
32template <
typename Sequence,
typename MapFunctor>
36 std::forward<MapFunctor>(
map));
40template <
typename Iterator,
typename MapFunctor>
46template <
typename Iterator,
typename MapFunctor>
53template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor>
57 ReduceFunctor &&reduce,
61 return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
62 (
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(
map),
63 std::forward<ReduceFunctor>(reduce), options);
66template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor>
69 ReduceFunctor &&reduce,
73 return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
75 std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce), options);
79template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
80 typename InitialValueType>
82template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
83 typename InitialValueType,
84 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
90 ReduceFunctor &&reduce,
91 InitialValueType &&initialValue,
95 return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>(
96 pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(
map),
97 std::forward<ReduceFunctor>(reduce),
98 ResultType(std::forward<InitialValueType>(initialValue)), options);
101template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
102 typename InitialValueType>
104template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
105 typename InitialValueType,
106 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
111 ReduceFunctor &&reduce,
112 InitialValueType &&initialValue,
116 return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
118 std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
119 ResultType(std::forward<InitialValueType>(initialValue)), options);
122template <
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
123 std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value,
int> = 0,
128 ReduceFunctor &&reduce,
132 return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
133 (
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(
map),
134 std::forward<ReduceFunctor>(reduce), options);
137template <
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
138 std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value,
int> = 0,
142 ReduceFunctor &&reduce,
146 return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
148 std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce), options);
152template <
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
typename ResultType,
153 typename InitialValueType>
155template <
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
typename InitialValueType,
156 std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value,
int> = 0,
158 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
164 ReduceFunctor &&reduce,
165 InitialValueType &&initialValue,
169 return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>(
170 pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(
map),
171 std::forward<ReduceFunctor>(reduce),
172 ResultType(std::forward<InitialValueType>(initialValue)), options);
176template <
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
typename ResultType,
177 typename InitialValueType>
179template <
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
typename InitialValueType,
180 std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value,
int> = 0,
182 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
187 ReduceFunctor &&reduce,
188 InitialValueType &&initialValue,
192 return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
194 std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
195 ResultType(std::forward<InitialValueType>(initialValue)), options);
199template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor>
204 ReduceFunctor &&reduce,
208 return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
209 (
pool,
begin,
end, std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
213template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor>
217 ReduceFunctor &&reduce,
221 return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
223 std::forward<ReduceFunctor>(reduce), options);
227template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
228 typename InitialValueType>
230template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
231 typename InitialValueType,
232 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
239 ReduceFunctor &&reduce,
240 InitialValueType &&initialValue,
244 return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
245 (
pool,
begin,
end, std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
246 ResultType(std::forward<InitialValueType>(initialValue)), options);
250template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
251 typename InitialValueType>
253template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
254 typename InitialValueType,
255 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
261 ReduceFunctor &&reduce,
262 InitialValueType &&initialValue,
266 return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
268 std::forward<ReduceFunctor>(reduce),
269 ResultType(std::forward<InitialValueType>(initialValue)), options);
272template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
278 ReduceFunctor &&reduce,
282 return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>(
283 pool,
begin,
end, std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
287template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
292 ReduceFunctor &&reduce,
296 return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
298 std::forward<ReduceFunctor>(reduce), options);
302template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
typename ResultType,
303 typename InitialValueType>
305template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
307 typename InitialValueType,
308 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
315 ReduceFunctor &&reduce,
316 InitialValueType &&initialValue,
320 return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
321 (
pool,
begin,
end, std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
322 ResultType(std::forward<InitialValueType>(initialValue)), options);
326template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
typename ResultType,
327 typename InitialValueType>
329template<
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
330 std::enable_if_t<QtPrivate::isIterator_v<Iterator>,
int> = 0,
332 typename InitialValueType,
333 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
339 ReduceFunctor &&reduce,
340 InitialValueType &&initialValue,
344 return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
346 std::forward<ReduceFunctor>(reduce),
347 ResultType(std::forward<InitialValueType>(initialValue)), options);
351template <
typename Sequence,
typename MapFunctor>
357 return startMapped<QtPrivate::MapResultType<Sequence, MapFunctor>>(
358 pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(
map));
361template <
typename Sequence,
typename MapFunctor>
366 return startMapped<QtPrivate::MapResultType<Sequence, MapFunctor>>
368 std::forward<MapFunctor>(
map));
372template <
typename Iterator,
typename MapFunctor>
379 return startMapped<QtPrivate::MapResultType<Iterator, MapFunctor>>(
383template <
typename Iterator,
typename MapFunctor>
389 return startMapped<QtPrivate::MapResultType<Iterator, MapFunctor>>
394template <
typename Sequence,
typename MapFunctor>
398 startMap(
pool, sequence.begin(), sequence.end(), std::forward<MapFunctor>(
map));
402template <
typename Sequence,
typename MapFunctor>
406 std::forward<MapFunctor>(
map));
411template <
typename Iterator,
typename MapFunctor>
418template <
typename Iterator,
typename MapFunctor>
422 std::forward<MapFunctor>(
map));
427template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor>
431 ReduceFunctor &&reduce,
436 mappedReduced<ResultType>(
pool, std::forward<Sequence>(sequence),
437 std::forward<MapFunctor>(
map),
438 std::forward<ReduceFunctor>(reduce), options);
439 return future.takeResult();
442template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor>
445 ReduceFunctor &&reduce,
450 mappedReduced<ResultType>(std::forward<Sequence>(sequence),
451 std::forward<MapFunctor>(
map),
452 std::forward<ReduceFunctor>(reduce), options);
453 return future.takeResult();
457template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
458 typename InitialValueType>
460template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
461 typename InitialValueType,
462 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
468 ReduceFunctor &&reduce,
469 InitialValueType &&initialValue,
474 pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(
map),
475 std::forward<ReduceFunctor>(reduce),
476 ResultType(std::forward<InitialValueType>(initialValue)), options);
477 return future.takeResult();
481template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
482 typename InitialValueType>
484template <
typename ResultType,
typename Sequence,
typename MapFunctor,
typename ReduceFunctor,
485 typename InitialValueType,
486 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
491 ReduceFunctor &&reduce,
492 InitialValueType &&initialValue,
497 std::forward<Sequence>(sequence), std::forward<MapFunctor>(
map),
498 std::forward<ReduceFunctor>(reduce),
499 ResultType(std::forward<InitialValueType>(initialValue)), options);
500 return future.takeResult();
503template <
typename MapFunctor,
typename ReduceFunctor,
typename Sequence,
504 std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value,
int> = 0,
509 ReduceFunctor &&reduce,
514 mappedReduced<ResultType>(
pool, std::forward<Sequence>(sequence),
515 std::forward<MapFunctor>(
map),
516 std::forward<ReduceFunctor>(reduce), options);
517 return future.takeResult();
520template <
typename MapFunctor,
typename ReduceFunctor,
typename Sequence,
521 std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value,
int> = 0,
525 ReduceFunctor &&reduce,
530 mappedReduced<ResultType>(std::forward<Sequence>(sequence),
531 std::forward<MapFunctor>(
map),
532 std::forward<ReduceFunctor>(reduce), options);
533 return future.takeResult();
537template <
typename MapFunctor,
typename ReduceFunctor,
typename Sequence,
typename ResultType,
538 typename InitialValueType>
540template <
typename MapFunctor,
typename ReduceFunctor,
typename Sequence,
typename InitialValueType,
541 std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value,
int> = 0,
543 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
549 ReduceFunctor &&reduce,
550 InitialValueType &&initialValue,
555 pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(
map),
556 std::forward<ReduceFunctor>(reduce),
557 ResultType(std::forward<InitialValueType>(initialValue)), options);
558 return future.takeResult();
562template <
typename MapFunctor,
typename ReduceFunctor,
typename Sequence,
typename ResultType,
563 typename InitialValueType>
565template<
typename MapFunctor,
typename ReduceFunctor,
typename Sequence,
typename InitialValueType,
566 std::enable_if_t<QtPrivate::isInvocable<MapFunctor, Sequence>::value,
int> = 0,
568 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
573 ReduceFunctor &&reduce,
574 InitialValueType &&initialValue,
579 std::forward<Sequence>(sequence), std::forward<MapFunctor>(
map),
580 std::forward<ReduceFunctor>(reduce),
581 ResultType(std::forward<InitialValueType>(initialValue)), options);
582 return future.takeResult();
586template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor>
591 ReduceFunctor &&reduce,
596 mappedReduced<ResultType>(
pool,
begin,
end, std::forward<MapFunctor>(
map),
597 std::forward<ReduceFunctor>(reduce), options);
598 return future.takeResult();
601template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor>
605 ReduceFunctor &&reduce,
610 mappedReduced<ResultType>(
begin,
end, std::forward<MapFunctor>(
map),
611 std::forward<ReduceFunctor>(reduce), options);
612 return future.takeResult();
616template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
617 typename InitialValueType>
619template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
620 typename InitialValueType,
621 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
628 ReduceFunctor &&reduce,
629 InitialValueType &&initialValue,
634 pool,
begin,
end, std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
635 ResultType(std::forward<InitialValueType>(initialValue)),
637 return future.takeResult();
641template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
642 typename InitialValueType>
644template <
typename ResultType,
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
645 typename InitialValueType,
646 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
652 ReduceFunctor &&reduce,
653 InitialValueType &&initialValue,
658 begin,
end, std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
659 ResultType(std::forward<InitialValueType>(initialValue)),
661 return future.takeResult();
664template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
670 ReduceFunctor &&reduce,
675 mappedReduced<ResultType>(
pool,
begin,
end, std::forward<MapFunctor>(
map),
676 std::forward<ReduceFunctor>(reduce), options);
677 return future.takeResult();
680template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
685 ReduceFunctor &&reduce,
690 mappedReduced<ResultType>(
begin,
end, std::forward<MapFunctor>(
map),
691 std::forward<ReduceFunctor>(reduce), options);
692 return future.takeResult();
696template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
typename ResultType,
697 typename InitialValueType>
699template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
701 typename InitialValueType,
702 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
709 ReduceFunctor &&reduce,
710 InitialValueType &&initialValue,
715 pool,
begin,
end, std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
716 ResultType(std::forward<InitialValueType>(initialValue)), options);
717 return future.takeResult();
721template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
typename ResultType,
722 typename InitialValueType>
724template <
typename Iterator,
typename MapFunctor,
typename ReduceFunctor,
725 std::enable_if_t<QtPrivate::isIterator_v<Iterator>,
int> = 0,
727 typename InitialValueType,
728 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
734 ReduceFunctor &&reduce,
735 InitialValueType &&initialValue,
740 begin,
end, std::forward<MapFunctor>(
map), std::forward<ReduceFunctor>(reduce),
741 ResultType(std::forward<InitialValueType>(initialValue)), options);
742 return future.takeResult();
746template <
typename OutputSequence,
typename InputSequence,
typename MapFunctor>
749 return blockingMappedReduced<OutputSequence>(
pool, std::forward<InputSequence>(sequence),
750 std::forward<MapFunctor>(
map),
754template <
typename OutputSequence,
typename InputSequence,
typename MapFunctor>
757 return blockingMappedReduced<OutputSequence>(
762template <
typename MapFunctor,
typename InputSequence>
766 MapFunctor>::ResultType;
767 return blockingMappedReduced<OutputSequence>(
pool, std::forward<InputSequence>(sequence),
768 std::forward<MapFunctor>(
map),
772template <
typename MapFunctor,
typename InputSequence>
776 MapFunctor>::ResultType;
778 std::forward<InputSequence>(sequence),
779 std::forward<MapFunctor>(
map),
784template <
typename Sequence,
typename Iterator,
typename MapFunctor>
787 return blockingMappedReduced<Sequence>(
pool,
begin,
end, std::forward<MapFunctor>(
map),
791template <
typename Sequence,
typename Iterator,
typename MapFunctor>
795 std::forward<MapFunctor>(
map),
799template <
typename Iterator,
typename MapFunctor>
803 return blockingMappedReduced<OutputSequence>(
pool,
begin,
end, std::forward<MapFunctor>(
map),
807template <
typename Iterator,
typename MapFunctor>
812 std::forward<MapFunctor>(
map),
static QThreadPool * globalInstance()
Returns the global QThreadPool instance.
QMap< QString, QString > map
[6]
Combined button and popup list for selecting options.
void blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor map)
Calls function once for each item in sequence.
QFuture< QtPrivate::MapResultType< Sequence, MapFunctor > > mapped(QThreadPool *pool, Sequence &&sequence, MapFunctor &&map)
QFuture< ResultType > mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&map, ReduceFunctor &&reduce, ReduceOptions options=ReduceOptions(UnorderedReduce|SequentialReduce))
ResultType blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&map, ReduceFunctor &&reduce, ReduceOptions options=ReduceOptions(UnorderedReduce|SequentialReduce))
ThreadEngineStarter< void > startMap(QThreadPool *pool, Iterator begin, Iterator end, Functor &&functor)
[qtconcurrentmapkernel-1]
OutputSequence blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&map)
Calls function once for each item in sequence and returns an OutputSequence containing the results.
typename MapResult< T, MapFunctor >::Type MapResultType
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
QFuture< void > future
[5]