4#ifndef QTCONCURRENT_FILTER_H
5#define QTCONCURRENT_FILTER_H
8#pragma qt_class(QtConcurrentFilter)
11#include <QtConcurrent/qtconcurrent_global.h>
13#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
15#include <QtConcurrent/qtconcurrentfilterkernel.h>
16#include <QtConcurrent/qtconcurrentfunctionwrappers.h>
23template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
25 KeepFunctor &&keep, ReduceFunctor &&reduce)
30 std::forward<ReduceFunctor>(reduce)));
34template <
typename Sequence,
typename KeepFunctor>
41template <
typename Sequence,
typename KeepFunctor>
49template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
53 ReduceFunctor &&reduce,
57 return startFilteredReduced<ResultType>(
pool, std::forward<Sequence>(sequence),
58 std::forward<KeepFunctor>(keep),
59 std::forward<ReduceFunctor>(reduce), options);
62template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
65 ReduceFunctor &&reduce,
69 return startFilteredReduced<ResultType>(
71 std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce), options);
75template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
76 typename InitialValueType>
78template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
79 typename InitialValueType,
80 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
86 ReduceFunctor &&reduce,
87 InitialValueType &&initialValue,
91 return startFilteredReduced<ResultType>(
92 pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
93 std::forward<ReduceFunctor>(reduce),
94 ResultType(std::forward<InitialValueType>(initialValue)), options);
98template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
99 typename InitialValueType>
101template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
102 typename InitialValueType,
103 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
108 ReduceFunctor &&reduce,
109 InitialValueType &&initialValue,
113 return startFilteredReduced<ResultType>(
115 std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
116 ResultType(std::forward<InitialValueType>(initialValue)), options);
120template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
121 std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value,
int> = 0,
126 ReduceFunctor &&reduce,
130 return startFilteredReduced<ResultType>(
pool, std::forward<Sequence>(sequence),
131 std::forward<KeepFunctor>(keep),
132 std::forward<ReduceFunctor>(reduce), options);
135template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
136 std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value,
int> = 0,
140 ReduceFunctor &&reduce,
144 return startFilteredReduced<ResultType>(
146 std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce), options);
149template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
150 typename InitialValueType,
151 std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value,
int> = 0,
153 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
158 ReduceFunctor &&reduce,
159 InitialValueType &&initialValue,
163 return startFilteredReduced<ResultType>(
164 pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
165 std::forward<ReduceFunctor>(reduce),
166 ResultType(std::forward<InitialValueType>(initialValue)), options);
169template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
170 typename InitialValueType,
171 std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value,
int> = 0,
173 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
177 ReduceFunctor &&reduce,
178 InitialValueType &&initialValue,
182 return startFilteredReduced<ResultType>(
184 std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
185 ResultType(std::forward<InitialValueType>(initialValue)), options);
190template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor>
195 ReduceFunctor &&reduce,
199 return startFilteredReduced<ResultType>(
pool,
begin,
end, std::forward<KeepFunctor>(keep),
200 std::forward<ReduceFunctor>(reduce), options);
203template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor>
207 ReduceFunctor &&reduce,
212 std::forward<KeepFunctor>(keep),
213 std::forward<ReduceFunctor>(reduce), options);
217template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
218 typename InitialValueType>
220template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
221 typename InitialValueType,
222 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
229 ReduceFunctor &&reduce,
230 InitialValueType &&initialValue,
234 return startFilteredReduced<ResultType>(
235 pool,
begin,
end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
236 ResultType(std::forward<InitialValueType>(initialValue)), options);
240template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
241 typename InitialValueType>
243template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
244 typename InitialValueType,
245 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
251 ReduceFunctor &&reduce,
252 InitialValueType &&initialValue,
256 return startFilteredReduced<ResultType>(
258 std::forward<ReduceFunctor>(reduce),
259 ResultType(std::forward<InitialValueType>(initialValue)), options);
263template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
269 ReduceFunctor &&reduce,
273 return startFilteredReduced<ResultType>(
pool,
begin,
end, std::forward<KeepFunctor>(keep),
274 std::forward<ReduceFunctor>(reduce), options);
277template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
282 ReduceFunctor &&reduce,
287 std::forward<KeepFunctor>(keep),
288 std::forward<ReduceFunctor>(reduce), options);
291template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
293 typename InitialValueType,
294 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
300 ReduceFunctor &&reduce,
301 InitialValueType &&initialValue,
305 return startFilteredReduced<ResultType>(
306 pool,
begin,
end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
307 ResultType(std::forward<InitialValueType>(initialValue)), options);
310template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
311 std::enable_if_t<QtPrivate::isIterator_v<Iterator>,
int> = 0,
313 typename InitialValueType,
314 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
319 ReduceFunctor &&reduce,
320 InitialValueType &&initialValue,
324 return startFilteredReduced<ResultType>(
326 std::forward<ReduceFunctor>(reduce),
327 ResultType(std::forward<InitialValueType>(initialValue)), options);
332template <
typename Sequence,
typename KeepFunctor>
336 return startFiltered(
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep));
339template <
typename Sequence,
typename KeepFunctor>
344 std::forward<KeepFunctor>(keep));
348template <
typename Iterator,
typename KeepFunctor>
357template <
typename Iterator,
typename KeepFunctor>
363 std::forward<KeepFunctor>(keep));
367template <
typename Sequence,
typename KeepFunctor>
374template <
typename Sequence,
typename KeepFunctor>
382template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
386 ReduceFunctor &&reduce,
391 pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
392 std::forward<ReduceFunctor>(reduce), options);
393 return future.takeResult();
396template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
399 ReduceFunctor &&reduce,
404 std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
405 std::forward<ReduceFunctor>(reduce), options);
406 return future.takeResult();
410template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
411 typename InitialValueType>
413template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
414 typename InitialValueType,
415 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
421 ReduceFunctor &&reduce,
422 InitialValueType &&initialValue,
427 pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
428 std::forward<ReduceFunctor>(reduce),
429 ResultType(std::forward<InitialValueType>(initialValue)), options);
430 return future.takeResult();
434template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
435 typename InitialValueType>
437template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
438 typename InitialValueType,
439 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
444 ReduceFunctor &&reduce,
445 InitialValueType &&initialValue,
450 std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
451 std::forward<ReduceFunctor>(reduce),
452 ResultType(std::forward<InitialValueType>(initialValue)), options);
453 return future.takeResult();
457template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
458 std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value,
int> = 0,
463 ReduceFunctor &&reduce,
468 pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
469 std::forward<ReduceFunctor>(reduce), options);
470 return future.takeResult();
473template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
474 std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value,
int> = 0,
478 ReduceFunctor &&reduce,
483 std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
484 std::forward<ReduceFunctor>(reduce), options);
485 return future.takeResult();
488template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
489 typename InitialValueType,
490 std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value,
int> = 0,
492 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
497 ReduceFunctor &&reduce,
498 InitialValueType &&initialValue,
503 pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
504 std::forward<ReduceFunctor>(reduce),
505 ResultType(std::forward<InitialValueType>(initialValue)), options);
506 return future.takeResult();
509template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor,
510 typename InitialValueType,
511 std::enable_if_t<QtPrivate::isInvocable<KeepFunctor, Sequence>::value,
int> = 0,
513 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
517 ReduceFunctor &&reduce,
518 InitialValueType &&initialValue,
523 std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
524 std::forward<ReduceFunctor>(reduce),
525 ResultType(std::forward<InitialValueType>(initialValue)), options);
526 return future.takeResult();
531template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor>
536 ReduceFunctor &&reduce,
541 filteredReduced<ResultType>(
pool,
begin,
end, std::forward<KeepFunctor>(keep),
542 std::forward<ReduceFunctor>(reduce), options);
543 return future.takeResult();
546template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor>
550 ReduceFunctor &&reduce,
555 filteredReduced<ResultType>(
begin,
end, std::forward<KeepFunctor>(keep),
556 std::forward<ReduceFunctor>(reduce), options);
557 return future.takeResult();
561template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
562 typename InitialValueType>
564template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
565 typename InitialValueType,
566 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
573 ReduceFunctor &&reduce,
574 InitialValueType &&initialValue,
579 pool,
begin,
end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
580 ResultType(std::forward<InitialValueType>(initialValue)), options);
581 return future.takeResult();
585template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
586 typename InitialValueType>
588template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
589 typename InitialValueType,
590 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
596 ReduceFunctor &&reduce,
597 InitialValueType &&initialValue,
602 begin,
end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
603 ResultType(std::forward<InitialValueType>(initialValue)), options);
604 return future.takeResult();
608template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
614 ReduceFunctor &&reduce,
619 filteredReduced<ResultType>(
pool,
begin,
end, std::forward<KeepFunctor>(keep),
620 std::forward<ReduceFunctor>(reduce), options);
621 return future.takeResult();
624template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
629 ReduceFunctor &&reduce,
634 filteredReduced<ResultType>(
begin,
end, std::forward<KeepFunctor>(keep),
635 std::forward<ReduceFunctor>(reduce), options);
636 return future.takeResult();
639template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
641 typename InitialValueType,
642 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
646 Iterator
end, KeepFunctor &&keep,
647 ReduceFunctor &&reduce,
648 InitialValueType &&initialValue,
653 pool,
begin,
end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
654 ResultType(std::forward<InitialValueType>(initialValue)), options);
655 return future.takeResult();
658template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor,
659 std::enable_if_t<QtPrivate::isIterator_v<Iterator>,
int> = 0,
661 typename InitialValueType,
662 std::enable_if_t<QtPrivate::isInitialValueCompatible_v<InitialValueType, ResultType>,
667 ReduceFunctor &&reduce,
668 InitialValueType &&initialValue,
673 begin,
end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
674 ResultType(std::forward<InitialValueType>(initialValue)), options);
675 return future.takeResult();
680template <
typename Sequence,
typename KeepFunctor>
683 return blockingFilteredReduced<std::decay_t<Sequence>>(
684 pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
688template <
typename Sequence,
typename KeepFunctor>
691 return blockingFilteredReduced<std::decay_t<Sequence>>(
697template <
typename OutputSequence,
typename Iterator,
typename KeepFunctor>
700 return blockingFilteredReduced<OutputSequence>(
pool,
begin,
end,
701 std::forward<KeepFunctor>(keep),
705template <
typename OutputSequence,
typename Iterator,
typename KeepFunctor>
709 std::forward<KeepFunctor>(keep),
static QThreadPool * globalInstance()
Returns the global QThreadPool instance.
Combined button and popup list for selecting options.
QFuture< typename std::decay_t< Sequence >::value_type > filtered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&keep)
Calls filterFunction once for each item in sequence and returns a new Sequence of kept items.
QFuture< ResultType > filteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&keep, ReduceFunctor &&reduce, ReduceOptions options=ReduceOptions(UnorderedReduce|SequentialReduce))
void blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&keep)
Calls filterFunction once for each item in sequence.
ThreadEngineStarter< void > filterInternal(QThreadPool *pool, Sequence &sequence, KeepFunctor &&keep, ReduceFunctor &&reduce)
[QtConcurrent-1]
ThreadEngineStarter< typename qValueType< Iterator >::value_type > startFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&functor)
[QtConcurrent-2]
ThreadEngineStarter< typename ThreadEngine::ResultType > startThreadEngine(ThreadEngine *threadEngine)
[qtconcurrentthreadengine-1]
ResultType blockingFilteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&keep, ReduceFunctor &&reduce, ReduceOptions options=ReduceOptions(UnorderedReduce|SequentialReduce))
std::decay_t< Sequence > blockingFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&keep)
Calls filterFunction once for each item in sequence and returns a new Sequence of kept items.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
QFuture< void > future
[5]