author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QTCONCURRENT_MAP_H |
|
43 |
#define QTCONCURRENT_MAP_H |
|
44 |
||
45 |
#include <QtCore/qglobal.h> |
|
46 |
||
47 |
#ifndef QT_NO_CONCURRENT |
|
48 |
||
49 |
#include <QtCore/qtconcurrentmapkernel.h> |
|
50 |
#include <QtCore/qtconcurrentreducekernel.h> |
|
51 |
#include <QtCore/qtconcurrentfunctionwrappers.h> |
|
52 |
#include <QtCore/qstringlist.h> |
|
53 |
||
54 |
QT_BEGIN_HEADER |
|
55 |
QT_BEGIN_NAMESPACE |
|
56 |
||
57 |
QT_MODULE(Core) |
|
58 |
||
59 |
#ifdef qdoc |
|
60 |
||
61 |
namespace QtConcurrent { |
|
62 |
||
63 |
QFuture<void> map(Sequence &sequence, MapFunction function); |
|
64 |
QFuture<void> map(Iterator begin, Iterator end, MapFunction function); |
|
65 |
||
66 |
template <typename T> |
|
67 |
QFuture<T> mapped(const Sequence &sequence, MapFunction function); |
|
68 |
template <typename T> |
|
69 |
QFuture<T> mapped(ConstIterator begin, ConstIterator end, MapFunction function); |
|
70 |
||
71 |
template <typename T> |
|
72 |
QFuture<T> mappedReduced(const Sequence &sequence, |
|
73 |
MapFunction function, |
|
74 |
ReduceFunction function, |
|
75 |
QtConcurrent::ReduceOptions options = UnorderedReduce | SequentialReduce); |
|
76 |
template <typename T> |
|
77 |
QFuture<T> mappedReduced(ConstIterator begin, |
|
78 |
ConstIterator end, |
|
79 |
MapFunction function, |
|
80 |
ReduceFunction function, |
|
81 |
QtConcurrent::ReduceOptions options = UnorderedReduce | SequentialReduce); |
|
82 |
||
83 |
void blockingMap(Sequence &sequence, MapFunction function); |
|
84 |
void blockingMap(Iterator begin, Iterator end, MapFunction function); |
|
85 |
||
86 |
template <typename T> |
|
87 |
T blockingMapped(const Sequence &sequence, MapFunction function); |
|
88 |
template <typename T> |
|
89 |
T blockingMapped(ConstIterator begin, ConstIterator end, MapFunction function); |
|
90 |
||
91 |
template <typename T> |
|
92 |
T blockingMappedReduced(const Sequence &sequence, |
|
93 |
MapFunction function, |
|
94 |
ReduceFunction function, |
|
95 |
QtConcurrent::ReduceOptions options = UnorderedReduce | SequentialReduce); |
|
96 |
template <typename T> |
|
97 |
T blockingMappedReduced(ConstIterator begin, |
|
98 |
ConstIterator end, |
|
99 |
MapFunction function, |
|
100 |
ReduceFunction function, |
|
101 |
QtConcurrent::ReduceOptions options = UnorderedReduce | SequentialReduce); |
|
102 |
||
103 |
} // namespace QtConcurrent |
|
104 |
||
105 |
#else |
|
106 |
||
107 |
namespace QtConcurrent { |
|
108 |
||
109 |
// map() on sequences |
|
110 |
template <typename Sequence, typename MapFunctor> |
|
111 |
QFuture<void> map(Sequence &sequence, MapFunctor map) |
|
112 |
{ |
|
113 |
return startMap(sequence.begin(), sequence.end(), map); |
|
114 |
} |
|
115 |
||
116 |
template <typename Sequence, typename T, typename U> |
|
117 |
QFuture<void> map(Sequence &sequence, T (map)(U)) |
|
118 |
{ |
|
119 |
return startMap(sequence.begin(), sequence.end(), FunctionWrapper1<T, U>(map)); |
|
120 |
} |
|
121 |
||
122 |
template <typename Sequence, typename T, typename C> |
|
123 |
QFuture<void> map(Sequence &sequence, T (C::*map)()) |
|
124 |
{ |
|
125 |
return startMap(sequence.begin(), sequence.end(), MemberFunctionWrapper<T, C>(map)); |
|
126 |
} |
|
127 |
||
128 |
// map() on iterators |
|
129 |
template <typename Iterator, typename MapFunctor> |
|
130 |
QFuture<void> map(Iterator begin, Iterator end, MapFunctor map) |
|
131 |
{ |
|
132 |
return startMap(begin, end, map); |
|
133 |
} |
|
134 |
||
135 |
template <typename Iterator, typename T, typename U> |
|
136 |
QFuture<void> map(Iterator begin, Iterator end, T (map)(U)) |
|
137 |
{ |
|
138 |
return startMap(begin, end, FunctionWrapper1<T, U>(map)); |
|
139 |
} |
|
140 |
||
141 |
template <typename Iterator, typename T, typename C> |
|
142 |
QFuture<void> map(Iterator begin, Iterator end, T (C::*map)()) |
|
143 |
{ |
|
144 |
return startMap(begin, end, MemberFunctionWrapper<T, C>(map)); |
|
145 |
} |
|
146 |
||
147 |
// mappedReduced() for sequences. |
|
148 |
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> |
|
149 |
QFuture<ResultType> mappedReduced(const Sequence &sequence, |
|
150 |
MapFunctor map, |
|
151 |
ReduceFunctor reduce, |
|
152 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
153 |
{ |
|
154 |
return startMappedReduced<typename MapFunctor::result_type, ResultType> |
|
155 |
(sequence, map, reduce, options); |
|
156 |
} |
|
157 |
||
158 |
template <typename Sequence, typename MapFunctor, typename T, typename U, typename V> |
|
159 |
QFuture<U> mappedReduced(const Sequence &sequence, |
|
160 |
MapFunctor map, |
|
161 |
T (reduce)(U &, V), |
|
162 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
163 |
{ |
|
164 |
return startMappedReduced<typename MapFunctor::result_type, U> |
|
165 |
(sequence, map, FunctionWrapper2<T, U &, V>(reduce), options); |
|
166 |
} |
|
167 |
||
168 |
template <typename Sequence, typename MapFunctor, typename T, typename C, typename U> |
|
169 |
QFuture<C> mappedReduced(const Sequence &sequence, |
|
170 |
MapFunctor map, |
|
171 |
T (C::*reduce)(U), |
|
172 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
173 |
{ |
|
174 |
return startMappedReduced<typename MapFunctor::result_type, C> |
|
175 |
(sequence, map, MemberFunctionWrapper1<T, C, U>(reduce), options); |
|
176 |
} |
|
177 |
||
178 |
template <typename ResultType, typename Sequence, typename T, typename U, typename ReduceFunctor> |
|
179 |
QFuture<ResultType> mappedReduced(const Sequence &sequence, |
|
180 |
T (map)(U), |
|
181 |
ReduceFunctor reduce, |
|
182 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
183 |
{ |
|
184 |
return startMappedReduced<T, ResultType> |
|
185 |
(sequence, FunctionWrapper1<T, U>(map), reduce, options); |
|
186 |
} |
|
187 |
||
188 |
template <typename ResultType, typename Sequence, typename T, typename C, typename ReduceFunctor> |
|
189 |
QFuture<ResultType> mappedReduced(const Sequence &sequence, |
|
190 |
T (C::*map)() const, |
|
191 |
ReduceFunctor reduce, |
|
192 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
193 |
{ |
|
194 |
return startMappedReduced<T, ResultType> |
|
195 |
(sequence, ConstMemberFunctionWrapper<T, C>(map), reduce, options); |
|
196 |
} |
|
197 |
||
198 |
template <typename Sequence, typename T, typename U, typename V, typename W, typename X> |
|
199 |
QFuture<W> mappedReduced(const Sequence &sequence, |
|
200 |
T (map)(U), |
|
201 |
V (reduce)(W &, X), |
|
202 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
203 |
{ |
|
204 |
return startMappedReduced<T, W> |
|
205 |
(sequence, FunctionWrapper1<T, U>(map), FunctionWrapper2<V, W &, X>(reduce), options); |
|
206 |
} |
|
207 |
||
208 |
template <typename Sequence, typename T, typename C, typename U, typename V, typename W> |
|
209 |
QFuture<V> mappedReduced(const Sequence &sequence, |
|
210 |
T (C::*map)() const, |
|
211 |
U (reduce)(V &, W), |
|
212 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
213 |
{ |
|
214 |
return startMappedReduced<T, V> (sequence, ConstMemberFunctionWrapper<T, C>(map), |
|
215 |
FunctionWrapper2<U, V &, W>(reduce), options); |
|
216 |
} |
|
217 |
||
218 |
template <typename Sequence, typename T, typename U, typename V, typename C, typename W> |
|
219 |
QFuture<C> mappedReduced(const Sequence &sequence, |
|
220 |
T (map)(U), |
|
221 |
V (C::*reduce)(W), |
|
222 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
223 |
{ |
|
224 |
return startMappedReduced<T, C> (sequence, FunctionWrapper1<T, U>(map), |
|
225 |
MemberFunctionWrapper1<V, C, W>(reduce), options); |
|
226 |
} |
|
227 |
||
228 |
template <typename Sequence, typename T, typename C, typename U,typename D, typename V> |
|
229 |
QFuture<D> mappedReduced(const Sequence &sequence, |
|
230 |
T (C::*map)() const, |
|
231 |
U (D::*reduce)(V), |
|
232 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
233 |
{ |
|
234 |
return startMappedReduced<T, D>(sequence, ConstMemberFunctionWrapper<T, C>(map), |
|
235 |
MemberFunctionWrapper1<U, D, V>(reduce), options); |
|
236 |
} |
|
237 |
||
238 |
// mappedReduced() for iterators |
|
239 |
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> |
|
240 |
QFuture<ResultType> mappedReduced(Iterator begin, |
|
241 |
Iterator end, |
|
242 |
MapFunctor map, |
|
243 |
ReduceFunctor reduce, |
|
244 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
245 |
{ |
|
246 |
return startMappedReduced<ResultType, typename MapFunctor::result_type> |
|
247 |
(begin, end, map, reduce, options); |
|
248 |
} |
|
249 |
||
250 |
template <typename Iterator, typename MapFunctor, typename T, typename U, typename V> |
|
251 |
QFuture<U> mappedReduced(Iterator begin, |
|
252 |
Iterator end, |
|
253 |
MapFunctor map, |
|
254 |
T (reduce)(U &, V), |
|
255 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
256 |
{ |
|
257 |
return startMappedReduced<typename MapFunctor::result_type, U> |
|
258 |
(begin, end, map, FunctionWrapper2<T, U &, V>(reduce), options); |
|
259 |
} |
|
260 |
||
261 |
template <typename Iterator, typename MapFunctor, typename T, typename C, typename U> |
|
262 |
QFuture<C> mappedReduced(Iterator begin, |
|
263 |
Iterator end, |
|
264 |
MapFunctor map, |
|
265 |
T (C::*reduce)(U), |
|
266 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
267 |
{ |
|
268 |
return startMappedReduced<typename MapFunctor::result_type, C> |
|
269 |
(begin, end, map, MemberFunctionWrapper1<T, C, U>(reduce), options); |
|
270 |
} |
|
271 |
||
272 |
template <typename ResultType, typename Iterator, typename T, typename U, typename ReduceFunctor> |
|
273 |
QFuture<ResultType> mappedReduced(Iterator begin, |
|
274 |
Iterator end, |
|
275 |
T (map)(U), |
|
276 |
ReduceFunctor reduce, |
|
277 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
278 |
{ |
|
279 |
return startMappedReduced<T, ResultType> |
|
280 |
(begin, end, FunctionWrapper1<T, U>(map), reduce, options); |
|
281 |
} |
|
282 |
||
283 |
template <typename ResultType, typename Iterator, typename T, typename C, typename ReduceFunctor> |
|
284 |
QFuture<ResultType> mappedReduced(Iterator begin, |
|
285 |
Iterator end, |
|
286 |
T (C::*map)() const, |
|
287 |
ReduceFunctor reduce, |
|
288 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
289 |
{ |
|
290 |
return startMappedReduced<T, ResultType> |
|
291 |
(begin, end, ConstMemberFunctionWrapper<T, C>(map), reduce, options); |
|
292 |
} |
|
293 |
||
294 |
template <typename Iterator, typename T, typename U, typename V, typename W, typename X> |
|
295 |
QFuture<W> mappedReduced(Iterator begin, |
|
296 |
Iterator end, |
|
297 |
T (map)(U), |
|
298 |
V (reduce)(W &, X), |
|
299 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
300 |
{ |
|
301 |
return startMappedReduced<T, W> |
|
302 |
(begin, end, FunctionWrapper1<T, U>(map), FunctionWrapper2<V, W &, X>(reduce), options); |
|
303 |
} |
|
304 |
||
305 |
template <typename Iterator, typename T, typename C, typename U, typename V, typename W> |
|
306 |
QFuture<V> mappedReduced(Iterator begin, |
|
307 |
Iterator end, |
|
308 |
T (C::*map)() const, |
|
309 |
U (reduce)(V &, W), |
|
310 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
311 |
{ |
|
312 |
return startMappedReduced<T, V>(begin, end, ConstMemberFunctionWrapper<T, C>(map), |
|
313 |
FunctionWrapper2<U, V &, W>(reduce), options); |
|
314 |
} |
|
315 |
||
316 |
template <typename Iterator, typename T, typename U, typename V, typename C, typename W> |
|
317 |
QFuture<C> mappedReduced(Iterator begin, |
|
318 |
Iterator end, |
|
319 |
T (map)(U), |
|
320 |
V (C::*reduce)(W), |
|
321 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
322 |
{ |
|
323 |
return startMappedReduced<T, C> |
|
324 |
(begin, end, FunctionWrapper1<T, U>(map), MemberFunctionWrapper1<V, C, W>(reduce), options); |
|
325 |
} |
|
326 |
||
327 |
template <typename Iterator, typename T, typename C, typename U,typename D, typename V> |
|
328 |
QFuture<D> mappedReduced(Iterator begin, |
|
329 |
Iterator end, |
|
330 |
T (C::*map)() const, |
|
331 |
U (D::*reduce)(V), |
|
332 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
333 |
{ |
|
334 |
return startMappedReduced<T, D>(begin, end, ConstMemberFunctionWrapper<T, C>(map), |
|
335 |
MemberFunctionWrapper1<U, D, V>(reduce), options); |
|
336 |
} |
|
337 |
||
338 |
// mapped() for sequences |
|
339 |
template <typename Sequence, typename MapFunctor> |
|
340 |
QFuture<typename MapFunctor::result_type> mapped(const Sequence &sequence, MapFunctor map) |
|
341 |
{ |
|
342 |
return startMapped<typename MapFunctor::result_type>(sequence, map); |
|
343 |
} |
|
344 |
||
345 |
template <typename Sequence, typename T, typename U> |
|
346 |
QFuture<T> mapped(const Sequence &sequence, T (map)(U)) |
|
347 |
{ |
|
348 |
return startMapped<T>(sequence, FunctionWrapper1<T, U>(map)); |
|
349 |
} |
|
350 |
||
351 |
template <typename Sequence, typename T, typename C> |
|
352 |
QFuture<T> mapped(const Sequence &sequence, T (C::*map)() const) |
|
353 |
{ |
|
354 |
return startMapped<T>(sequence, ConstMemberFunctionWrapper<T, C>(map)); |
|
355 |
} |
|
356 |
||
357 |
// mapped() for iterator ranges. |
|
358 |
template <typename Iterator, typename MapFunctor> |
|
359 |
QFuture<typename MapFunctor::result_type> mapped(Iterator begin, Iterator end, MapFunctor map) |
|
360 |
{ |
|
361 |
return startMapped<Q_TYPENAME MapFunctor::result_type>(begin, end, map); |
|
362 |
} |
|
363 |
||
364 |
template <typename Iterator, typename T, typename U> |
|
365 |
QFuture<T> mapped(Iterator begin, Iterator end, T (map)(U)) |
|
366 |
{ |
|
367 |
return startMapped<T>(begin, end, FunctionWrapper1<T, U>(map)); |
|
368 |
} |
|
369 |
||
370 |
template <typename Iterator, typename T, typename C> |
|
371 |
QFuture<T> mapped(Iterator begin, Iterator end, T (C::*map)() const) |
|
372 |
{ |
|
373 |
return startMapped<T>(begin, end, ConstMemberFunctionWrapper<T, C>(map)); |
|
374 |
} |
|
375 |
||
376 |
||
377 |
template <typename Sequence, typename MapFunctor> |
|
378 |
void blockingMap(Sequence &sequence, MapFunctor map) |
|
379 |
{ |
|
380 |
startMap(sequence.begin(), sequence.end(), map).startBlocking(); |
|
381 |
} |
|
382 |
||
383 |
template <typename Sequence, typename T, typename U> |
|
384 |
void blockingMap(Sequence &sequence, T (map)(U)) |
|
385 |
{ |
|
386 |
startMap(sequence.begin(), sequence.end(), QtConcurrent::FunctionWrapper1<T, U>(map)).startBlocking(); |
|
387 |
} |
|
388 |
||
389 |
template <typename Sequence, typename T, typename C> |
|
390 |
void blockingMap(Sequence &sequence, T (C::*map)()) |
|
391 |
{ |
|
392 |
startMap(sequence.begin(), sequence.end(), QtConcurrent::MemberFunctionWrapper<T, C>(map)).startBlocking(); |
|
393 |
} |
|
394 |
||
395 |
template <typename Iterator, typename MapFunctor> |
|
396 |
void blockingMap(Iterator begin, Iterator end, MapFunctor map) |
|
397 |
{ |
|
398 |
startMap(begin, end, map).startBlocking(); |
|
399 |
} |
|
400 |
||
401 |
template <typename Iterator, typename T, typename U> |
|
402 |
void blockingMap(Iterator begin, Iterator end, T (map)(U)) |
|
403 |
{ |
|
404 |
startMap(begin, end, QtConcurrent::FunctionWrapper1<T, U>(map)).startBlocking(); |
|
405 |
} |
|
406 |
||
407 |
template <typename Iterator, typename T, typename C> |
|
408 |
void blockingMap(Iterator begin, Iterator end, T (C::*map)()) |
|
409 |
{ |
|
410 |
startMap(begin, end, QtConcurrent::MemberFunctionWrapper<T, C>(map)).startBlocking(); |
|
411 |
} |
|
412 |
||
413 |
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> |
|
414 |
ResultType blockingMappedReduced(const Sequence &sequence, |
|
415 |
MapFunctor map, |
|
416 |
ReduceFunctor reduce, |
|
417 |
ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) |
|
418 |
{ |
|
419 |
return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, ResultType> |
|
420 |
(sequence, map, reduce, options).startBlocking(); |
|
421 |
} |
|
422 |
||
423 |
template <typename Sequence, typename MapFunctor, typename T, typename U, typename V> |
|
424 |
U blockingMappedReduced(const Sequence &sequence, |
|
425 |
MapFunctor map, |
|
426 |
T (reduce)(U &, V), |
|
427 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
428 |
{ |
|
429 |
return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, U> |
|
430 |
(sequence, |
|
431 |
map, |
|
432 |
QtConcurrent::FunctionWrapper2<T, U &, V>(reduce), |
|
433 |
options) |
|
434 |
.startBlocking(); |
|
435 |
} |
|
436 |
||
437 |
template <typename Sequence, typename MapFunctor, typename T, typename C, typename U> |
|
438 |
C blockingMappedReduced(const Sequence &sequence, |
|
439 |
MapFunctor map, |
|
440 |
T (C::*reduce)(U), |
|
441 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
442 |
{ |
|
443 |
return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, C> |
|
444 |
(sequence, |
|
445 |
map, |
|
446 |
QtConcurrent::MemberFunctionWrapper1<T, C, U>(reduce), |
|
447 |
options) |
|
448 |
.startBlocking(); |
|
449 |
} |
|
450 |
||
451 |
template <typename ResultType, typename Sequence, typename T, typename U, typename ReduceFunctor> |
|
452 |
ResultType blockingMappedReduced(const Sequence &sequence, |
|
453 |
T (map)(U), |
|
454 |
ReduceFunctor reduce, |
|
455 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
456 |
{ |
|
457 |
return QtConcurrent::startMappedReduced<T, ResultType> |
|
458 |
(sequence, |
|
459 |
QtConcurrent::FunctionWrapper1<T, U>(map), |
|
460 |
reduce, |
|
461 |
options) |
|
462 |
.startBlocking(); |
|
463 |
} |
|
464 |
||
465 |
template <typename ResultType, typename Sequence, typename T, typename C, typename ReduceFunctor> |
|
466 |
ResultType blockingMappedReduced(const Sequence &sequence, |
|
467 |
T (C::*map)() const, |
|
468 |
ReduceFunctor reduce, |
|
469 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
470 |
{ |
|
471 |
return QtConcurrent::startMappedReduced<T, ResultType> |
|
472 |
(sequence, |
|
473 |
QtConcurrent::ConstMemberFunctionWrapper<T, C>(map), |
|
474 |
reduce, |
|
475 |
options) |
|
476 |
.startBlocking(); |
|
477 |
} |
|
478 |
||
479 |
template <typename Sequence, typename T, typename U, typename V, typename W, typename X> |
|
480 |
W blockingMappedReduced(const Sequence &sequence, |
|
481 |
T (map)(U), |
|
482 |
V (reduce)(W &, X), |
|
483 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
484 |
{ |
|
485 |
return QtConcurrent::startMappedReduced<T, W> |
|
486 |
(sequence, |
|
487 |
QtConcurrent::FunctionWrapper1<T, U>(map), |
|
488 |
QtConcurrent::FunctionWrapper2<V, W &, X>(reduce), |
|
489 |
options) |
|
490 |
.startBlocking(); |
|
491 |
} |
|
492 |
||
493 |
template <typename Sequence, typename T, typename C, typename U, typename V, typename W> |
|
494 |
V blockingMappedReduced(const Sequence &sequence, |
|
495 |
T (C::*map)() const, |
|
496 |
U (reduce)(V &, W), |
|
497 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
498 |
{ |
|
499 |
return QtConcurrent::startMappedReduced<T, V> |
|
500 |
(sequence, |
|
501 |
QtConcurrent::ConstMemberFunctionWrapper<T, C>(map), |
|
502 |
QtConcurrent::FunctionWrapper2<U, V &, W>(reduce), |
|
503 |
options) |
|
504 |
.startBlocking(); |
|
505 |
} |
|
506 |
||
507 |
template <typename Sequence, typename T, typename U, typename V, typename C, typename W> |
|
508 |
C blockingMappedReduced(const Sequence &sequence, |
|
509 |
T (map)(U), |
|
510 |
V (C::*reduce)(W), |
|
511 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
512 |
{ |
|
513 |
return QtConcurrent::startMappedReduced<T, C> |
|
514 |
(sequence, |
|
515 |
QtConcurrent::FunctionWrapper1<T, U>(map), |
|
516 |
QtConcurrent::MemberFunctionWrapper1<V, C, W>(reduce), |
|
517 |
options) |
|
518 |
.startBlocking(); |
|
519 |
} |
|
520 |
||
521 |
template <typename Sequence, typename T, typename C, typename U,typename D, typename V> |
|
522 |
D blockingMappedReduced(const Sequence &sequence, |
|
523 |
T (C::*map)() const, |
|
524 |
U (D::*reduce)(V), |
|
525 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
526 |
{ |
|
527 |
return QtConcurrent::startMappedReduced<T, D> |
|
528 |
(sequence, |
|
529 |
QtConcurrent::ConstMemberFunctionWrapper<T, C>(map), |
|
530 |
QtConcurrent::MemberFunctionWrapper1<U, D, V>(reduce), |
|
531 |
options) |
|
532 |
.startBlocking(); |
|
533 |
} |
|
534 |
||
535 |
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> |
|
536 |
ResultType blockingMappedReduced(Iterator begin, |
|
537 |
Iterator end, |
|
538 |
MapFunctor map, |
|
539 |
ReduceFunctor reduce, |
|
540 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
541 |
{ |
|
542 |
return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, ResultType> |
|
543 |
(begin, end, map, reduce, options).startBlocking(); |
|
544 |
} |
|
545 |
||
546 |
template <typename Iterator, typename MapFunctor, typename T, typename U, typename V> |
|
547 |
U blockingMappedReduced(Iterator begin, |
|
548 |
Iterator end, |
|
549 |
MapFunctor map, |
|
550 |
T (reduce)(U &, V), |
|
551 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
552 |
{ |
|
553 |
return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, U> |
|
554 |
(begin, |
|
555 |
end, |
|
556 |
map, |
|
557 |
QtConcurrent::FunctionWrapper2<T, U &, V>(reduce), |
|
558 |
options) |
|
559 |
.startBlocking(); |
|
560 |
} |
|
561 |
||
562 |
template <typename Iterator, typename MapFunctor, typename T, typename C, typename U> |
|
563 |
C blockingMappedReduced(Iterator begin, |
|
564 |
Iterator end, |
|
565 |
MapFunctor map, |
|
566 |
T (C::*reduce)(U), |
|
567 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
568 |
{ |
|
569 |
return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, C> |
|
570 |
(begin, |
|
571 |
end, |
|
572 |
map, |
|
573 |
QtConcurrent::MemberFunctionWrapper1<T, C, U>(reduce), |
|
574 |
options) |
|
575 |
.startBlocking(); |
|
576 |
} |
|
577 |
||
578 |
template <typename ResultType, typename Iterator, typename T, typename U, typename ReduceFunctor> |
|
579 |
ResultType blockingMappedReduced(Iterator begin, |
|
580 |
Iterator end, |
|
581 |
T (map)(U), |
|
582 |
ReduceFunctor reduce, |
|
583 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
584 |
{ |
|
585 |
return QtConcurrent::startMappedReduced<T, ResultType> |
|
586 |
(begin, |
|
587 |
end, |
|
588 |
QtConcurrent::FunctionWrapper1<T, U>(map), |
|
589 |
reduce, |
|
590 |
options) |
|
591 |
.startBlocking(); |
|
592 |
} |
|
593 |
||
594 |
template <typename ResultType, typename Iterator, typename T, typename C, typename ReduceFunctor> |
|
595 |
ResultType blockingMappedReduced(Iterator begin, |
|
596 |
Iterator end, |
|
597 |
T (C::*map)() const, |
|
598 |
ReduceFunctor reduce, |
|
599 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
600 |
{ |
|
601 |
return QtConcurrent::startMappedReduced<T, ResultType> |
|
602 |
(begin, |
|
603 |
end, |
|
604 |
QtConcurrent::ConstMemberFunctionWrapper<T, C>(map), |
|
605 |
reduce, |
|
606 |
options) |
|
607 |
.startBlocking(); |
|
608 |
} |
|
609 |
||
610 |
template <typename Iterator, typename T, typename U, typename V, typename W, typename X> |
|
611 |
W blockingMappedReduced(Iterator begin, |
|
612 |
Iterator end, |
|
613 |
T (map)(U), |
|
614 |
V (reduce)(W &, X), |
|
615 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
616 |
{ |
|
617 |
return QtConcurrent::startMappedReduced<T, W> |
|
618 |
(begin, |
|
619 |
end, |
|
620 |
QtConcurrent::FunctionWrapper1<T, U>(map), |
|
621 |
QtConcurrent::FunctionWrapper2<V, W &, X>(reduce), |
|
622 |
options) |
|
623 |
.startBlocking(); |
|
624 |
} |
|
625 |
||
626 |
template <typename Iterator, typename T, typename C, typename U, typename V, typename W> |
|
627 |
V blockingMappedReduced(Iterator begin, |
|
628 |
Iterator end, |
|
629 |
T (C::*map)() const, |
|
630 |
U (reduce)(V &, W), |
|
631 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
632 |
{ |
|
633 |
return QtConcurrent::startMappedReduced<T, V> |
|
634 |
(begin, |
|
635 |
end, |
|
636 |
QtConcurrent::ConstMemberFunctionWrapper<T, C>(map), |
|
637 |
QtConcurrent::FunctionWrapper2<U, V &, W>(reduce), |
|
638 |
options) |
|
639 |
.startBlocking(); |
|
640 |
} |
|
641 |
||
642 |
template <typename Iterator, typename T, typename U, typename V, typename C, typename W> |
|
643 |
C blockingMappedReduced(Iterator begin, |
|
644 |
Iterator end, |
|
645 |
T (map)(U), |
|
646 |
V (C::*reduce)(W), |
|
647 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
648 |
{ |
|
649 |
return QtConcurrent::startMappedReduced<T, C> |
|
650 |
(begin, |
|
651 |
end, |
|
652 |
QtConcurrent::FunctionWrapper1<T, U>(map), |
|
653 |
QtConcurrent::MemberFunctionWrapper1<V, C, W>(reduce), |
|
654 |
options) |
|
655 |
.startBlocking(); |
|
656 |
} |
|
657 |
||
658 |
template <typename Iterator, typename T, typename C, typename U,typename D, typename V> |
|
659 |
D blockingMappedReduced(Iterator begin, |
|
660 |
Iterator end, |
|
661 |
T (C::*map)() const, |
|
662 |
U (D::*reduce)(V), |
|
663 |
QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) |
|
664 |
{ |
|
665 |
return QtConcurrent::startMappedReduced<T, D> |
|
666 |
(begin, |
|
667 |
end, |
|
668 |
QtConcurrent::ConstMemberFunctionWrapper<T, C>(map), |
|
669 |
QtConcurrent::MemberFunctionWrapper1<U, D, V>(reduce), |
|
670 |
options) |
|
671 |
.startBlocking(); |
|
672 |
} |
|
673 |
||
674 |
// mapped() for sequences with a different putput sequence type. |
|
675 |
template <typename OutputSequence, typename InputSequence, typename MapFunctor> |
|
676 |
OutputSequence blockingMapped(const InputSequence &sequence, MapFunctor map) |
|
677 |
{ |
|
678 |
return blockingMappedReduced(sequence, map, &OutputSequence::push_back, |
|
679 |
QtConcurrent::OrderedReduce); |
|
680 |
} |
|
681 |
||
682 |
template <typename OutputSequence, typename InputSequence, typename T, typename U> |
|
683 |
OutputSequence blockingMapped(const InputSequence &sequence, T (map)(U)) |
|
684 |
{ |
|
685 |
return blockingMappedReduced(sequence, map, &OutputSequence::push_back, |
|
686 |
QtConcurrent::OrderedReduce); |
|
687 |
} |
|
688 |
||
689 |
template <typename OutputSequence, typename InputSequence, typename T, typename C> |
|
690 |
OutputSequence blockingMapped(const InputSequence &sequence, T (C::*map)() const) |
|
691 |
{ |
|
692 |
return blockingMappedReduced(sequence, map, &OutputSequence::push_back, |
|
693 |
QtConcurrent::OrderedReduce); |
|
694 |
} |
|
695 |
#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS |
|
696 |
||
697 |
// overloads for changing the container value type: |
|
698 |
template <template <typename> class Sequence, typename MapFunctor, typename T> |
|
699 |
Sequence<typename MapFunctor::result_type> blockingMapped(const Sequence<T> &sequence, MapFunctor map) |
|
700 |
{ |
|
701 |
typedef Sequence<typename MapFunctor::result_type> OutputSequence; |
|
702 |
return blockingMappedReduced(sequence, map, &OutputSequence::push_back, |
|
703 |
QtConcurrent::OrderedReduce); |
|
704 |
} |
|
705 |
||
706 |
template <template <typename> class Sequence, typename T, typename U, typename V> |
|
707 |
Sequence<U> blockingMapped(const Sequence<T> &sequence, U (map)(V)) |
|
708 |
{ |
|
709 |
typedef Sequence<U> OutputSequence; |
|
710 |
return blockingMappedReduced(sequence, map, &OutputSequence::push_back, |
|
711 |
QtConcurrent::OrderedReduce); |
|
712 |
} |
|
713 |
||
714 |
template <template <typename> class Sequence, typename T, typename U, typename C> |
|
715 |
Sequence<U> blockingMapped(const Sequence<T> &sequence, U (C::*map)() const) |
|
716 |
{ |
|
717 |
typedef Sequence<U> OutputSequence; |
|
718 |
return blockingMappedReduced(sequence, map, &OutputSequence::push_back, |
|
719 |
QtConcurrent::OrderedReduce); |
|
720 |
} |
|
721 |
||
722 |
#endif // QT_NO_TEMPLATE_TEMPLATE_PARAMETER |
|
723 |
||
724 |
// overloads for changing the container value type from a QStringList: |
|
725 |
template <typename MapFunctor> |
|
726 |
QList<typename MapFunctor::result_type> blockingMapped(const QStringList &sequence, MapFunctor map) |
|
727 |
{ |
|
728 |
typedef QList<typename MapFunctor::result_type> OutputSequence; |
|
729 |
return blockingMappedReduced(sequence, map, &OutputSequence::push_back, |
|
730 |
QtConcurrent::OrderedReduce); |
|
731 |
} |
|
732 |
||
733 |
template <typename U, typename V> |
|
734 |
QList<U> blockingMapped(const QStringList &sequence, U (map)(V)) |
|
735 |
{ |
|
736 |
typedef QList<U> OutputSequence; |
|
737 |
return blockingMappedReduced(sequence, map, &OutputSequence::push_back, |
|
738 |
QtConcurrent::OrderedReduce); |
|
739 |
} |
|
740 |
||
741 |
template <typename U, typename C> |
|
742 |
QList<U> blockingMapped(const QStringList &sequence, U (C::*map)() const) |
|
743 |
{ |
|
744 |
typedef QList<U> OutputSequence; |
|
745 |
return blockingMappedReduced(sequence, map, &OutputSequence::push_back, |
|
746 |
QtConcurrent::OrderedReduce); |
|
747 |
} |
|
748 |
||
749 |
// mapped() for iterator ranges |
|
750 |
template <typename Sequence, typename Iterator, typename MapFunctor> |
|
751 |
Sequence blockingMapped(Iterator begin, Iterator end, MapFunctor map) |
|
752 |
{ |
|
753 |
return blockingMappedReduced(begin, end, map, &Sequence::push_back, |
|
754 |
QtConcurrent::OrderedReduce); |
|
755 |
} |
|
756 |
||
757 |
template <typename Sequence, typename Iterator, typename T, typename U> |
|
758 |
Sequence blockingMapped(Iterator begin, Iterator end, T (map)(U)) |
|
759 |
{ |
|
760 |
return blockingMappedReduced(begin, end, map, &Sequence::push_back, |
|
761 |
QtConcurrent::OrderedReduce); |
|
762 |
} |
|
763 |
||
764 |
template <typename Sequence, typename Iterator, typename T, typename C> |
|
765 |
Sequence blockingMapped(Iterator begin, Iterator end, T (C::*map)() const) |
|
766 |
{ |
|
767 |
return blockingMappedReduced(begin, end, map, &Sequence::push_back, |
|
768 |
QtConcurrent::OrderedReduce); |
|
769 |
} |
|
770 |
||
771 |
} // namespace QtConcurrent |
|
772 |
||
773 |
#endif // qdoc |
|
774 |
||
775 |
QT_END_NAMESPACE |
|
776 |
QT_END_HEADER |
|
777 |
||
778 |
#endif // QT_NO_CONCURRENT |
|
779 |
||
780 |
#endif |