- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qtconcurrentmap.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtCore module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QTCONCURRENT_MAP_H
    00043 #define QTCONCURRENT_MAP_H
    00044
    00045 #include <QtCore/qglobal.h>
    00046
    00047 #ifndef QT_NO_CONCURRENT
    00048
    00049 #include <QtCore/qtconcurrentmapkernel.h>
    00050 #include <QtCore/qtconcurrentreducekernel.h>
    00051 #include <QtCore/qtconcurrentfunctionwrappers.h>
    00052 #include <QtCore/qstringlist.h>
    00053
    00054 QT_BEGIN_HEADER
    00055 QT_BEGIN_NAMESPACE
    00056
    00057 QT_MODULE(Core)
    00058
    00059 #ifdef qdoc
    00060
    00061 namespace QtConcurrent {
    00062
    00063     QFuture<void> map(Sequence &sequence, MapFunction function);
    00064     QFuture<void> map(Iterator begin, Iterator end, MapFunction function);
    00065
    00066     template <typename T>
    00067     QFuture<T> mapped(const Sequence &sequence, MapFunction function);
    00068     template <typename T>
    00069     QFuture<T> mapped(ConstIterator begin, ConstIterator end, MapFunction function);
    00070
    00071     template <typename T>
    00072     QFuture<T> mappedReduced(const Sequence &sequence,
    00073                              MapFunction function,
    00074                              ReduceFunction function,
    00075                              QtConcurrent::ReduceOptions options = UnorderedReduce | SequentialReduce);
    00076     template <typename T>
    00077     QFuture<T> mappedReduced(ConstIterator begin,
    00078                              ConstIterator end,
    00079                              MapFunction function,
    00080                              ReduceFunction function,
    00081                              QtConcurrent::ReduceOptions options = UnorderedReduce | SequentialReduce);
    00082
    00083     void blockingMap(Sequence &sequence, MapFunction function);
    00084     void blockingMap(Iterator begin, Iterator end, MapFunction function);
    00085
    00086     template <typename T>
    00087     T blockingMapped(const Sequence &sequence, MapFunction function);
    00088     template <typename T>
    00089     T blockingMapped(ConstIterator begin, ConstIterator end, MapFunction function);
    00090
    00091     template <typename T>
    00092     T blockingMappedReduced(const Sequence &sequence,
    00093                             MapFunction function,
    00094                             ReduceFunction function,
    00095                             QtConcurrent::ReduceOptions options = UnorderedReduce | SequentialReduce);
    00096     template <typename T>
    00097     T blockingMappedReduced(ConstIterator begin,
    00098                             ConstIterator end,
    00099                             MapFunction function,
    00100                             ReduceFunction function,
    00101                             QtConcurrent::ReduceOptions options = UnorderedReduce | SequentialReduce);
    00102
    00103 } // namespace QtConcurrent
    00104
    00105 #else
    00106
    00107 namespace QtConcurrent {
    00108
    00109 // map() on sequences
    00110 template <typename Sequence, typename MapFunctor>
    00111 QFuture<void> map(Sequence &sequence, MapFunctor map)
    00112 {
    00113     return startMap(sequence.begin(), sequence.end(), map);
    00114 }
    00115
    00116 template <typename Sequence, typename T, typename U>
    00117 QFuture<void> map(Sequence &sequence, T (map)(U))
    00118 {
    00119     return startMap(sequence.begin(), sequence.end(), FunctionWrapper1<T, U>(map));
    00120 }
    00121
    00122 template <typename Sequence, typename T, typename C>
    00123 QFuture<void> map(Sequence &sequence, T (C::*map)())
    00124 {
    00125     return startMap(sequence.begin(), sequence.end(), MemberFunctionWrapper<T, C>(map));
    00126 }
    00127
    00128 // map() on iterators
    00129 template <typename Iterator, typename MapFunctor>
    00130 QFuture<void> map(Iterator begin, Iterator end, MapFunctor map)
    00131 {
    00132     return startMap(begin, end, map);
    00133 }
    00134
    00135 template <typename Iterator, typename T, typename U>
    00136 QFuture<void> map(Iterator begin, Iterator end, T (map)(U))
    00137 {
    00138     return startMap(begin, end, FunctionWrapper1<T, U>(map));
    00139 }
    00140
    00141 template <typename Iterator, typename T, typename C>
    00142 QFuture<void> map(Iterator begin, Iterator end, T (C::*map)())
    00143 {
    00144     return startMap(begin, end, MemberFunctionWrapper<T, C>(map));
    00145 }
    00146
    00147 // mappedReduced() for sequences.
    00148 template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
    00149 QFuture<ResultType> mappedReduced(const Sequence &sequence,
    00150                                   MapFunctor map,
    00151                                   ReduceFunctor reduce,
    00152                                   ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00153 {
    00154     return startMappedReduced<typename MapFunctor::result_type, ResultType>
    00155     (sequence, map, reduce, options);
    00156 }
    00157
    00158 template <typename Sequence, typename MapFunctor, typename T, typename U, typename V>
    00159 QFuture<U> mappedReduced(const Sequence &sequence,
    00160                          MapFunctor map,
    00161                          T (reduce)(U &, V),
    00162                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00163 {
    00164     return startMappedReduced<typename MapFunctor::result_type, U>
    00165     (sequence, map, FunctionWrapper2<T, U &, V>(reduce), options);
    00166 }
    00167
    00168 template <typename Sequence, typename MapFunctor, typename T, typename C, typename U>
    00169 QFuture<C> mappedReduced(const Sequence &sequence,
    00170                          MapFunctor map,
    00171                          T (C::*reduce)(U),
    00172                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00173 {
    00174     return startMappedReduced<typename MapFunctor::result_type, C>
    00175     (sequence, map, MemberFunctionWrapper1<T, C, U>(reduce), options);
    00176 }
    00177
    00178 template <typename ResultType, typename Sequence, typename T, typename U, typename ReduceFunctor>
    00179 QFuture<ResultType> mappedReduced(const Sequence &sequence,
    00180                                   T (map)(U),
    00181                                   ReduceFunctor reduce,
    00182                                   ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00183 {
    00184     return startMappedReduced<T, ResultType>
    00185     (sequence, FunctionWrapper1<T, U>(map), reduce, options);
    00186 }
    00187
    00188 template <typename ResultType, typename Sequence, typename T, typename C, typename ReduceFunctor>
    00189 QFuture<ResultType> mappedReduced(const Sequence &sequence,
    00190                                   T (C::*map)() const,
    00191                                   ReduceFunctor reduce,
    00192                                   ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00193 {
    00194     return startMappedReduced<T, ResultType>
    00195     (sequence, ConstMemberFunctionWrapper<T, C>(map), reduce, options);
    00196 }
    00197
    00198 template <typename Sequence, typename T, typename U, typename V, typename W, typename X>
    00199 QFuture<W> mappedReduced(const Sequence &sequence,
    00200                          T (map)(U),
    00201                          V (reduce)(W &, X),
    00202                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00203 {
    00204     return startMappedReduced<T, W>
    00205     (sequence, FunctionWrapper1<T, U>(map), FunctionWrapper2<V, W &, X>(reduce), options);
    00206 }
    00207
    00208 template <typename Sequence, typename T, typename C, typename U, typename V, typename W>
    00209 QFuture<V> mappedReduced(const Sequence &sequence,
    00210                          T (C::*map)() const,
    00211                          U (reduce)(V &, W),
    00212                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00213 {
    00214     return startMappedReduced<T, V> (sequence, ConstMemberFunctionWrapper<T, C>(map),
    00215                                     FunctionWrapper2<U, V &, W>(reduce), options);
    00216 }
    00217
    00218 template <typename Sequence, typename T, typename U, typename V, typename C, typename W>
    00219 QFuture<C> mappedReduced(const Sequence &sequence,
    00220                          T (map)(U),
    00221                          V (C::*reduce)(W),
    00222                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00223 {
    00224     return startMappedReduced<T, C> (sequence, FunctionWrapper1<T, U>(map),
    00225                                      MemberFunctionWrapper1<V, C, W>(reduce), options);
    00226 }
    00227
    00228 template <typename Sequence, typename T, typename C, typename U,typename D, typename V>
    00229 QFuture<D> mappedReduced(const Sequence &sequence,
    00230                          T (C::*map)() const,
    00231                          U (D::*reduce)(V),
    00232                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00233 {
    00234     return startMappedReduced<T, D>(sequence, ConstMemberFunctionWrapper<T, C>(map),
    00235                                     MemberFunctionWrapper1<U, D, V>(reduce), options);
    00236 }
    00237
    00238 // mappedReduced() for iterators
    00239 template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
    00240 QFuture<ResultType> mappedReduced(Iterator begin,
    00241                                   Iterator end,
    00242                                   MapFunctor map,
    00243                                   ReduceFunctor reduce,
    00244                                   ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00245 {
    00246     return startMappedReduced<ResultType, typename MapFunctor::result_type>
    00247     (begin, end, map, reduce, options);
    00248 }
    00249
    00250 template <typename Iterator, typename MapFunctor, typename T, typename U, typename V>
    00251 QFuture<U> mappedReduced(Iterator begin,
    00252                          Iterator end,
    00253                          MapFunctor map,
    00254                          T (reduce)(U &, V),
    00255                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00256 {
    00257     return startMappedReduced<typename MapFunctor::result_type, U>
    00258     (begin, end, map, FunctionWrapper2<T, U &, V>(reduce), options);
    00259 }
    00260
    00261 template <typename Iterator, typename MapFunctor, typename T, typename C, typename U>
    00262 QFuture<C> mappedReduced(Iterator begin,
    00263                          Iterator end,
    00264                          MapFunctor map,
    00265                          T (C::*reduce)(U),
    00266                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00267 {
    00268     return startMappedReduced<typename MapFunctor::result_type, C>
    00269     (begin, end, map, MemberFunctionWrapper1<T, C, U>(reduce), options);
    00270 }
    00271
    00272 template <typename ResultType, typename Iterator, typename T, typename U, typename ReduceFunctor>
    00273 QFuture<ResultType> mappedReduced(Iterator begin,
    00274                                   Iterator end,
    00275                                   T (map)(U),
    00276                                   ReduceFunctor reduce,
    00277                                   ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00278 {
    00279     return startMappedReduced<T, ResultType>
    00280     (begin, end, FunctionWrapper1<T, U>(map), reduce, options);
    00281 }
    00282
    00283 template <typename ResultType, typename Iterator, typename T, typename C, typename ReduceFunctor>
    00284 QFuture<ResultType> mappedReduced(Iterator begin,
    00285                                   Iterator end,
    00286                                   T (C::*map)() const,
    00287                                   ReduceFunctor reduce,
    00288                                   ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00289 {
    00290     return startMappedReduced<T, ResultType>
    00291     (begin, end, ConstMemberFunctionWrapper<T, C>(map), reduce, options);
    00292 }
    00293
    00294 template <typename Iterator, typename T, typename U, typename V, typename W, typename X>
    00295 QFuture<W> mappedReduced(Iterator begin,
    00296                          Iterator end,
    00297                          T (map)(U),
    00298                          V (reduce)(W &, X),
    00299                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00300 {
    00301     return startMappedReduced<T, W>
    00302     (begin, end, FunctionWrapper1<T, U>(map), FunctionWrapper2<V, W &, X>(reduce), options);
    00303 }
    00304
    00305 template <typename Iterator, typename T, typename C, typename U, typename V, typename W>
    00306 QFuture<V> mappedReduced(Iterator begin,
    00307                          Iterator end,
    00308                          T (C::*map)() const,
    00309                          U (reduce)(V &, W),
    00310                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00311 {
    00312     return startMappedReduced<T, V>(begin, end, ConstMemberFunctionWrapper<T, C>(map),
    00313                                    FunctionWrapper2<U, V &, W>(reduce), options);
    00314 }
    00315
    00316 template <typename Iterator, typename T, typename U, typename V, typename C, typename W>
    00317 QFuture<C> mappedReduced(Iterator begin,
    00318                          Iterator end,
    00319                          T (map)(U),
    00320                          V (C::*reduce)(W),
    00321                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00322 {
    00323     return startMappedReduced<T, C>
    00324     (begin, end, FunctionWrapper1<T, U>(map), MemberFunctionWrapper1<V, C, W>(reduce), options);
    00325 }
    00326
    00327 template <typename Iterator, typename T, typename C, typename U,typename D, typename V>
    00328 QFuture<D> mappedReduced(Iterator begin,
    00329                          Iterator end,
    00330                          T (C::*map)() const,
    00331                          U (D::*reduce)(V),
    00332                          ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00333 {
    00334     return startMappedReduced<T, D>(begin, end, ConstMemberFunctionWrapper<T, C>(map),
    00335                                     MemberFunctionWrapper1<U, D, V>(reduce), options);
    00336 }
    00337
    00338 // mapped() for sequences
    00339 template <typename Sequence, typename MapFunctor>
    00340 QFuture<typename MapFunctor::result_type> mapped(const Sequence &sequence, MapFunctor map)
    00341 {
    00342     return startMapped<typename MapFunctor::result_type>(sequence, map);
    00343 }
    00344
    00345 template <typename Sequence, typename T, typename U>
    00346 QFuture<T> mapped(const Sequence &sequence, T (map)(U))
    00347 {
    00348    return startMapped<T>(sequence, FunctionWrapper1<T, U>(map));
    00349 }
    00350
    00351 template <typename Sequence, typename T, typename C>
    00352 QFuture<T> mapped(const Sequence &sequence, T (C::*map)() const)
    00353 {
    00354     return startMapped<T>(sequence, ConstMemberFunctionWrapper<T, C>(map));
    00355 }
    00356
    00357 // mapped() for iterator ranges.
    00358 template <typename Iterator, typename MapFunctor>
    00359 QFuture<typename MapFunctor::result_type> mapped(Iterator begin, Iterator end, MapFunctor map)
    00360 {
    00361     return startMapped<Q_TYPENAME MapFunctor::result_type>(begin, end, map);
    00362 }
    00363
    00364 template <typename Iterator, typename T, typename U>
    00365 QFuture<T> mapped(Iterator begin, Iterator end, T (map)(U))
    00366 {
    00367     return startMapped<T>(begin, end, FunctionWrapper1<T, U>(map));
    00368 }
    00369
    00370 template <typename Iterator, typename T, typename C>
    00371 QFuture<T> mapped(Iterator begin, Iterator end, T (C::*map)() const)
    00372 {
    00373     return startMapped<T>(begin, end, ConstMemberFunctionWrapper<T, C>(map));
    00374 }
    00375
    00376
    00377 template <typename Sequence, typename MapFunctor>
    00378 void blockingMap(Sequence &sequence, MapFunctor map)
    00379 {
    00380     startMap(sequence.begin(), sequence.end(), map).startBlocking();
    00381 }
    00382
    00383 template <typename Sequence, typename T, typename U>
    00384 void blockingMap(Sequence &sequence, T (map)(U))
    00385 {
    00386     startMap(sequence.begin(), sequence.end(), QtConcurrent::FunctionWrapper1<T, U>(map)).startBlocking();
    00387 }
    00388
    00389 template <typename Sequence, typename T, typename C>
    00390 void blockingMap(Sequence &sequence, T (C::*map)())
    00391 {
    00392     startMap(sequence.begin(), sequence.end(), QtConcurrent::MemberFunctionWrapper<T, C>(map)).startBlocking();
    00393 }
    00394
    00395 template <typename Iterator, typename MapFunctor>
    00396 void blockingMap(Iterator begin, Iterator end, MapFunctor map)
    00397 {
    00398     startMap(begin, end, map).startBlocking();
    00399 }
    00400
    00401 template <typename Iterator, typename T, typename U>
    00402 void blockingMap(Iterator begin, Iterator end, T (map)(U))
    00403 {
    00404     startMap(begin, end, QtConcurrent::FunctionWrapper1<T, U>(map)).startBlocking();
    00405 }
    00406
    00407 template <typename Iterator, typename T, typename C>
    00408 void blockingMap(Iterator begin, Iterator end, T (C::*map)())
    00409 {
    00410     startMap(begin, end, QtConcurrent::MemberFunctionWrapper<T, C>(map)).startBlocking();
    00411 }
    00412
    00413 template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
    00414 ResultType blockingMappedReduced(const Sequence &sequence,
    00415                                  MapFunctor map,
    00416                                  ReduceFunctor reduce,
    00417                                  ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00418 {
    00419     return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, ResultType>
    00420     (sequence, map, reduce, options).startBlocking();
    00421 }
    00422
    00423 template <typename Sequence, typename MapFunctor, typename T, typename U, typename V>
    00424 U blockingMappedReduced(const Sequence &sequence,
    00425                         MapFunctor map,
    00426                         T (reduce)(U &, V),
    00427                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00428 {
    00429     return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, U>
    00430         (sequence,
    00431          map,
    00432          QtConcurrent::FunctionWrapper2<T, U &, V>(reduce),
    00433          options)
    00434         .startBlocking();
    00435 }
    00436
    00437 template <typename Sequence, typename MapFunctor, typename T, typename C, typename U>
    00438 C blockingMappedReduced(const Sequence &sequence,
    00439                         MapFunctor map,
    00440                         T (C::*reduce)(U),
    00441                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00442 {
    00443     return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, C>
    00444         (sequence,
    00445          map,
    00446          QtConcurrent::MemberFunctionWrapper1<T, C, U>(reduce),
    00447          options)
    00448         .startBlocking();
    00449 }
    00450
    00451 template <typename ResultType, typename Sequence, typename T, typename U, typename ReduceFunctor>
    00452 ResultType blockingMappedReduced(const Sequence &sequence,
    00453                                  T (map)(U),
    00454                                  ReduceFunctor reduce,
    00455                                  QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00456 {
    00457     return QtConcurrent::startMappedReduced<T, ResultType>
    00458         (sequence,
    00459          QtConcurrent::FunctionWrapper1<T, U>(map),
    00460          reduce,
    00461          options)
    00462         .startBlocking();
    00463 }
    00464
    00465 template <typename ResultType, typename Sequence, typename T, typename C, typename ReduceFunctor>
    00466 ResultType blockingMappedReduced(const Sequence &sequence,
    00467                                  T (C::*map)() const,
    00468                                  ReduceFunctor reduce,
    00469                                  QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00470 {
    00471     return QtConcurrent::startMappedReduced<T, ResultType>
    00472         (sequence,
    00473          QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
    00474          reduce,
    00475          options)
    00476         .startBlocking();
    00477 }
    00478
    00479 template <typename Sequence, typename T, typename U, typename V, typename W, typename X>
    00480 W blockingMappedReduced(const Sequence &sequence,
    00481                         T (map)(U),
    00482                         V (reduce)(W &, X),
    00483                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00484 {
    00485     return QtConcurrent::startMappedReduced<T, W>
    00486         (sequence,
    00487          QtConcurrent::FunctionWrapper1<T, U>(map),
    00488          QtConcurrent::FunctionWrapper2<V, W &, X>(reduce),
    00489          options)
    00490         .startBlocking();
    00491 }
    00492
    00493 template <typename Sequence, typename T, typename C, typename U, typename V, typename W>
    00494 V blockingMappedReduced(const Sequence &sequence,
    00495                         T (C::*map)() const,
    00496                         U (reduce)(V &, W),
    00497                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00498 {
    00499     return QtConcurrent::startMappedReduced<T, V>
    00500         (sequence,
    00501          QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
    00502          QtConcurrent::FunctionWrapper2<U, V &, W>(reduce),
    00503          options)
    00504         .startBlocking();
    00505 }
    00506
    00507 template <typename Sequence, typename T, typename U, typename V, typename C, typename W>
    00508 C blockingMappedReduced(const Sequence &sequence,
    00509                         T (map)(U),
    00510                         V (C::*reduce)(W),
    00511                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00512 {
    00513     return QtConcurrent::startMappedReduced<T, C>
    00514         (sequence,
    00515          QtConcurrent::FunctionWrapper1<T, U>(map),
    00516          QtConcurrent::MemberFunctionWrapper1<V, C, W>(reduce),
    00517          options)
    00518         .startBlocking();
    00519 }
    00520
    00521 template <typename Sequence, typename T, typename C, typename U,typename D, typename V>
    00522 D blockingMappedReduced(const Sequence &sequence,
    00523                         T (C::*map)() const,
    00524                         U (D::*reduce)(V),
    00525                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00526 {
    00527     return QtConcurrent::startMappedReduced<T, D>
    00528         (sequence,
    00529          QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
    00530          QtConcurrent::MemberFunctionWrapper1<U, D, V>(reduce),
    00531          options)
    00532         .startBlocking();
    00533 }
    00534
    00535 template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
    00536 ResultType blockingMappedReduced(Iterator begin,
    00537                                  Iterator end,
    00538                                  MapFunctor map,
    00539                                  ReduceFunctor reduce,
    00540                                  QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00541 {
    00542     return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, ResultType>
    00543         (begin, end, map, reduce, options).startBlocking();
    00544 }
    00545
    00546 template <typename Iterator, typename MapFunctor, typename T, typename U, typename V>
    00547 U blockingMappedReduced(Iterator begin,
    00548                         Iterator end,
    00549                         MapFunctor map,
    00550                         T (reduce)(U &, V),
    00551                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00552 {
    00553     return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, U>
    00554         (begin,
    00555          end,
    00556          map,
    00557          QtConcurrent::FunctionWrapper2<T, U &, V>(reduce),
    00558          options)
    00559         .startBlocking();
    00560 }
    00561
    00562 template <typename Iterator, typename MapFunctor, typename T, typename C, typename U>
    00563 C blockingMappedReduced(Iterator begin,
    00564                         Iterator end,
    00565                         MapFunctor map,
    00566                         T (C::*reduce)(U),
    00567                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00568 {
    00569     return QtConcurrent::startMappedReduced<typename MapFunctor::result_type, C>
    00570         (begin,
    00571          end,
    00572          map,
    00573          QtConcurrent::MemberFunctionWrapper1<T, C, U>(reduce),
    00574          options)
    00575         .startBlocking();
    00576 }
    00577
    00578 template <typename ResultType, typename Iterator, typename T, typename U, typename ReduceFunctor>
    00579 ResultType blockingMappedReduced(Iterator begin,
    00580                                  Iterator end,
    00581                                  T (map)(U),
    00582                                  ReduceFunctor reduce,
    00583                                  QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00584 {
    00585     return QtConcurrent::startMappedReduced<T, ResultType>
    00586         (begin,
    00587          end,
    00588          QtConcurrent::FunctionWrapper1<T, U>(map),
    00589          reduce,
    00590          options)
    00591         .startBlocking();
    00592 }
    00593
    00594 template <typename ResultType, typename Iterator, typename T, typename C, typename ReduceFunctor>
    00595 ResultType blockingMappedReduced(Iterator begin,
    00596                                  Iterator end,
    00597                                  T (C::*map)() const,
    00598                                  ReduceFunctor reduce,
    00599                                  QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00600 {
    00601     return QtConcurrent::startMappedReduced<T, ResultType>
    00602         (begin,
    00603          end,
    00604          QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
    00605          reduce,
    00606          options)
    00607         .startBlocking();
    00608 }
    00609
    00610 template <typename Iterator, typename T, typename U, typename V, typename W, typename X>
    00611 W blockingMappedReduced(Iterator begin,
    00612                         Iterator end,
    00613                         T (map)(U),
    00614                         V (reduce)(W &, X),
    00615                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00616 {
    00617     return QtConcurrent::startMappedReduced<T, W>
    00618         (begin,
    00619          end,
    00620          QtConcurrent::FunctionWrapper1<T, U>(map),
    00621          QtConcurrent::FunctionWrapper2<V, W &, X>(reduce),
    00622          options)
    00623         .startBlocking();
    00624 }
    00625
    00626 template <typename Iterator, typename T, typename C, typename U, typename V, typename W>
    00627 V blockingMappedReduced(Iterator begin,
    00628                         Iterator end,
    00629                         T (C::*map)() const,
    00630                         U (reduce)(V &, W),
    00631                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00632 {
    00633     return QtConcurrent::startMappedReduced<T, V>
    00634         (begin,
    00635          end,
    00636          QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
    00637          QtConcurrent::FunctionWrapper2<U, V &, W>(reduce),
    00638          options)
    00639         .startBlocking();
    00640 }
    00641
    00642 template <typename Iterator, typename T, typename U, typename V, typename C, typename W>
    00643 C blockingMappedReduced(Iterator begin,
    00644                         Iterator end,
    00645                         T (map)(U),
    00646                         V (C::*reduce)(W),
    00647                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00648 {
    00649     return QtConcurrent::startMappedReduced<T, C>
    00650         (begin,
    00651          end,
    00652          QtConcurrent::FunctionWrapper1<T, U>(map),
    00653          QtConcurrent::MemberFunctionWrapper1<V, C, W>(reduce),
    00654          options)
    00655         .startBlocking();
    00656 }
    00657
    00658 template <typename Iterator, typename T, typename C, typename U,typename D, typename V>
    00659 D blockingMappedReduced(Iterator begin,
    00660                         Iterator end,
    00661                         T (C::*map)() const,
    00662                         U (D::*reduce)(V),
    00663                         QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce))
    00664 {
    00665     return QtConcurrent::startMappedReduced<T, D>
    00666         (begin,
    00667          end,
    00668          QtConcurrent::ConstMemberFunctionWrapper<T, C>(map),
    00669          QtConcurrent::MemberFunctionWrapper1<U, D, V>(reduce),
    00670          options)
    00671         .startBlocking();
    00672 }
    00673
    00674 // mapped() for sequences with a different putput sequence type.
    00675 template <typename OutputSequence, typename InputSequence, typename MapFunctor>
    00676 OutputSequence blockingMapped(const InputSequence &sequence, MapFunctor map)
    00677 {
    00678     return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
    00679                                  QtConcurrent::OrderedReduce);
    00680 }
    00681
    00682 template <typename OutputSequence, typename InputSequence, typename T, typename U>
    00683 OutputSequence blockingMapped(const InputSequence &sequence, T (map)(U))
    00684 {
    00685     return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
    00686                                  QtConcurrent::OrderedReduce);
    00687 }
    00688
    00689 template <typename OutputSequence, typename InputSequence, typename T, typename C>
    00690 OutputSequence blockingMapped(const InputSequence &sequence, T (C::*map)() const)
    00691 {
    00692     return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
    00693                                  QtConcurrent::OrderedReduce);
    00694 }
    00695 #ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
    00696
    00697 // overloads for changing the container value type:
    00698 template <template <typename> class Sequence, typename MapFunctor, typename T>
    00699 Sequence<typename MapFunctor::result_type> blockingMapped(const Sequence<T> &sequence, MapFunctor map)
    00700 {
    00701     typedef Sequence<typename MapFunctor::result_type> OutputSequence;
    00702     return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
    00703                                                QtConcurrent::OrderedReduce);
    00704 }
    00705
    00706 template <template <typename> class Sequence, typename T, typename U, typename V>
    00707 Sequence<U> blockingMapped(const Sequence<T> &sequence, U (map)(V))
    00708 {
    00709     typedef Sequence<U> OutputSequence;
    00710     return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
    00711                                                QtConcurrent::OrderedReduce);
    00712 }
    00713
    00714 template <template <typename> class Sequence, typename T, typename U, typename C>
    00715 Sequence<U> blockingMapped(const Sequence<T> &sequence, U (C::*map)() const)
    00716 {
    00717     typedef Sequence<U> OutputSequence;
    00718     return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
    00719                                                QtConcurrent::OrderedReduce);
    00720 }
    00721
    00722 #endif // QT_NO_TEMPLATE_TEMPLATE_PARAMETER
    00723
    00724 // overloads for changing the container value type from a QStringList:
    00725 template <typename MapFunctor>
    00726 QList<typename MapFunctor::result_type> blockingMapped(const QStringList &sequence, MapFunctor map)
    00727 {
    00728     typedef QList<typename MapFunctor::result_type> OutputSequence;
    00729     return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
    00730                                  QtConcurrent::OrderedReduce);
    00731 }
    00732
    00733 template <typename U, typename V>
    00734 QList<U> blockingMapped(const QStringList &sequence, U (map)(V))
    00735 {
    00736     typedef QList<U> OutputSequence;
    00737     return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
    00738                                  QtConcurrent::OrderedReduce);
    00739 }
    00740
    00741 template <typename U, typename C>
    00742 QList<U> blockingMapped(const QStringList &sequence, U (C::*map)() const)
    00743 {
    00744     typedef QList<U> OutputSequence;
    00745     return blockingMappedReduced(sequence, map, &OutputSequence::push_back,
    00746                                  QtConcurrent::OrderedReduce);
    00747 }
    00748
    00749 // mapped()  for iterator ranges
    00750 template <typename Sequence, typename Iterator, typename MapFunctor>
    00751 Sequence blockingMapped(Iterator begin, Iterator end, MapFunctor map)
    00752 {
    00753     return blockingMappedReduced(begin, end, map, &Sequence::push_back,
    00754                                  QtConcurrent::OrderedReduce);
    00755 }
    00756
    00757 template <typename Sequence, typename Iterator, typename T, typename U>
    00758 Sequence blockingMapped(Iterator begin, Iterator end, T (map)(U))
    00759 {
    00760     return blockingMappedReduced(begin, end, map, &Sequence::push_back,
    00761                                  QtConcurrent::OrderedReduce);
    00762 }
    00763
    00764 template <typename Sequence, typename Iterator, typename T, typename C>
    00765 Sequence blockingMapped(Iterator begin, Iterator end, T (C::*map)() const)
    00766 {
    00767     return blockingMappedReduced(begin, end, map, &Sequence::push_back,
    00768                                  QtConcurrent::OrderedReduce);
    00769 }
    00770
    00771 } // namespace QtConcurrent
    00772
    00773 #endif // qdoc
    00774
    00775 QT_END_NAMESPACE
    00776 QT_END_HEADER
    00777
    00778 #endif // QT_NO_CONCURRENT
    00779
    00780 #endif