42 #ifndef QTCONCURRENT_FILTER_H 43 #define QTCONCURRENT_FILTER_H 45 #include <QtCore/qglobal.h> 47 #ifndef QT_NO_CONCURRENT 49 #include <QtCore/qtconcurrentfilterkernel.h> 50 #include <QtCore/qtconcurrentfunctionwrappers.h> 70 FilterFunction filterFunction,
71 ReduceFunction reduceFunction,
76 FilterFunction filterFunction,
77 ReduceFunction reduceFunction,
80 void blockingFilter(Sequence &sequence, FilterFunction filterFunction);
82 template <
typename Sequence>
83 Sequence
blockingFiltered(
const Sequence &sequence, FilterFunction filterFunction);
84 template <
typename Sequence>
85 Sequence
blockingFiltered(ConstIterator begin, ConstIterator
end, FilterFunction filterFunction);
89 FilterFunction filterFunction,
90 ReduceFunction reduceFunction,
95 FilterFunction filterFunction,
96 ReduceFunction reduceFunction,
105 template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
106 ThreadEngineStarter<void> filterInternal(Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce)
108 typedef FilterKernel<Sequence, KeepFunctor, ReduceFunctor> KernelType;
109 return startThreadEngine(
new KernelType(sequence, keep, reduce));
113 template <
typename Sequence,
typename KeepFunctor>
116 return filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::PushBackWrapper());
120 template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
123 ReduceFunctor reduce,
126 return startFilteredReduced<ResultType>(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::createFunctionWrapper(reduce), options);
129 template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
132 ReduceFunctor reduce,
135 return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
137 QtPrivate::createFunctionWrapper(keep),
138 QtPrivate::createFunctionWrapper(reduce),
143 template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor>
147 ReduceFunctor reduce,
150 return startFilteredReduced<ResultType>(begin,
end, QtPrivate::createFunctionWrapper(keep), QtPrivate::createFunctionWrapper(reduce), options);
153 template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor>
157 ReduceFunctor reduce,
160 return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
162 QtPrivate::createFunctionWrapper(keep),
163 QtPrivate::createFunctionWrapper(reduce),
168 template <
typename Sequence,
typename KeepFunctor>
171 return startFiltered(sequence, QtPrivate::createFunctionWrapper(keep));
175 template <
typename Iterator,
typename KeepFunctor>
178 return startFiltered(begin, end, QtPrivate::createFunctionWrapper(keep));
182 template <
typename Sequence,
typename KeepFunctor>
185 filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::PushBackWrapper()).startBlocking();
189 template <
typename ResultType,
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
192 ReduceFunctor reduce,
195 return startFilteredReduced<ResultType>(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::createFunctionWrapper(reduce), options)
199 template <
typename Sequence,
typename KeepFunctor,
typename ReduceFunctor>
200 typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType
blockingFilteredReduced(
const Sequence &sequence,
202 ReduceFunctor reduce,
205 return blockingFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
207 QtPrivate::createFunctionWrapper(keep),
208 QtPrivate::createFunctionWrapper(reduce),
213 template <
typename ResultType,
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor>
217 ReduceFunctor reduce,
220 return startFilteredReduced<ResultType>
222 QtPrivate::createFunctionWrapper(keep),
223 QtPrivate::createFunctionWrapper(reduce),
228 template <
typename Iterator,
typename KeepFunctor,
typename ReduceFunctor>
232 ReduceFunctor reduce,
235 return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
237 QtPrivate::createFunctionWrapper(keep),
238 QtPrivate::createFunctionWrapper(reduce),
244 template <
typename Sequence,
typename KeepFunctor>
247 return startFilteredReduced<Sequence>(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::PushBackWrapper(),
OrderedReduce).startBlocking();
251 template <
typename OutputSequence,
typename Iterator,
typename KeepFunctor>
252 OutputSequence
blockingFiltered(Iterator begin, Iterator end, KeepFunctor keep)
254 return startFilteredReduced<OutputSequence>(begin,
end,
255 QtPrivate::createFunctionWrapper(keep),
256 QtPrivate::PushBackWrapper(),
267 #endif // QT_NO_CONCURRENT Sequence blockingFiltered(const Sequence &sequence, FilterFunction filterFunction)
Calls filterFunction once for each item in sequence and returns a new Sequence of kept items...
void blockingFilter(Sequence &sequence, FilterFunction filterFunction)
Calls filterFunction once for each item in sequence.
#define QT_END_NAMESPACE
This macro expands to.
QFuture< T > filteredReduced(const Sequence &sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions=UnorderedReduce|SequentialReduce)
#define QT_BEGIN_NAMESPACE
This macro expands to.
T blockingFilteredReduced(const Sequence &sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions=UnorderedReduce|SequentialReduce)
Calls filterFunction once for each item in sequence.
The QFuture class represents the result of an asynchronous computation.
The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded pro...
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
QFuture< T > filtered(const Sequence &sequence, FilterFunction filterFunction)
static const KeyPair *const end