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

- File List
- File Members

# qtconcurrentfilter.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_FILTER_H
    00043 #define QTCONCURRENT_FILTER_H
    00044
    00045 #include <QtCore/qglobal.h>
    00046
    00047 #ifndef QT_NO_CONCURRENT
    00048
    00049 #include <QtCore/qtconcurrentfilterkernel.h>
    00050 #include <QtCore/qtconcurrentfunctionwrappers.h>
    00051
    00052 QT_BEGIN_HEADER
    00053 QT_BEGIN_NAMESPACE
    00054
    00055 QT_MODULE(Core)
    00056
    00057 #ifdef qdoc
    00058
    00059 namespace QtConcurrent {
    00060
    00061     QFuture<void> filter(Sequence &sequence, FilterFunction filterFunction);
    00062
    00063     template <typename T>
    00064     QFuture<T> filtered(const Sequence &sequence, FilterFunction filterFunction);
    00065     template <typename T>
    00066     QFuture<T> filtered(ConstIterator begin, ConstIterator end, FilterFunction filterFunction);
    00067
    00068     template <typename T>
    00069     QFuture<T> filteredReduced(const Sequence &sequence,
    00070                                FilterFunction filterFunction,
    00071                                ReduceFunction reduceFunction,
    00072                                QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce);
    00073     template <typename T>
    00074     QFuture<T> filteredReduced(ConstIterator begin,
    00075                                ConstIterator end,
    00076                                FilterFunction filterFunction,
    00077                                ReduceFunction reduceFunction,
    00078                                QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce);
    00079
    00080     void blockingFilter(Sequence &sequence, FilterFunction filterFunction);
    00081
    00082     template <typename Sequence>
    00083     Sequence blockingFiltered(const Sequence &sequence, FilterFunction filterFunction);
    00084     template <typename Sequence>
    00085     Sequence blockingFiltered(ConstIterator begin, ConstIterator end, FilterFunction filterFunction);
    00086
    00087     template <typename T>
    00088     T blockingFilteredReduced(const Sequence &sequence,
    00089                               FilterFunction filterFunction,
    00090                               ReduceFunction reduceFunction,
    00091                               QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce);
    00092     template <typename T>
    00093     T blockingFilteredReduced(ConstIterator begin,
    00094                               ConstIterator end,
    00095                               FilterFunction filterFunction,
    00096                               ReduceFunction reduceFunction,
    00097                               QtConcurrent::ReduceOptions reduceOptions = UnorderedReduce | SequentialReduce);
    00098
    00099 } // namespace QtConcurrent
    00100
    00101 #else
    00102
    00103 namespace QtConcurrent {
    00104
    00105 template <typename Sequence, typename KeepFunctor, typename T, typename C, typename U>
    00106 ThreadEngineStarter<void> filterInternal(Sequence &sequence, KeepFunctor keep, T (C::*reduce)(U))
    00107 {
    00108     typedef MemberFunctionWrapper1<T, C, U> ReduceFunctor;
    00109     typedef typename Sequence::const_iterator Iterator;
    00110     typedef FilterKernel<Sequence, KeepFunctor, ReduceFunctor> KernelType;
    00111     return startThreadEngine(new KernelType(sequence, keep, reduce));
    00112 }
    00113
    00114 // filter() on sequences
    00115 template <typename Sequence, typename KeepFunctor>
    00116 QFuture<void> filter(Sequence &sequence, KeepFunctor keep)
    00117 {
    00118     return filterInternal(sequence, keep, &Sequence::push_back);
    00119 }
    00120
    00121 template <typename Sequence, typename T>
    00122 QFuture<void> filter(Sequence &sequence, bool (keep)(T))
    00123 {
    00124     return filterInternal(sequence, FunctionWrapper1<bool, T>(keep), &Sequence::push_back);
    00125 }
    00126
    00127 template <typename Sequence, typename C>
    00128 QFuture<void> filter(Sequence &sequence, bool (C::*keep)() const)
    00129 {
    00130     return filterInternal(sequence, ConstMemberFunctionWrapper<bool, C>(keep), &Sequence::push_back);
    00131 }
    00132
    00133 // filteredReduced() on sequences
    00134 template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
    00135 QFuture<ResultType> filteredReduced(const Sequence &sequence,
    00136                                     KeepFunctor keep,
    00137                                     ReduceFunctor reduce,
    00138                                     ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00139 {
    00140     return startFilteredReduced<ResultType>(sequence, keep, reduce, options);
    00141  }
    00142
    00143 template <typename ResultType, typename Sequence, typename T, typename ReduceFunctor>
    00144 QFuture<ResultType> filteredReduced(const Sequence &sequence,
    00145                                     bool (filter)(T),
    00146                                     ReduceFunctor reduce,
    00147                                     ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00148 {
    00149     return filteredReduced<ResultType>(sequence,
    00150                                        FunctionWrapper1<bool, T>(filter),
    00151                                        reduce,
    00152                                        options);
    00153 }
    00154
    00155 template <typename ResultType, typename Sequence, typename C, typename ReduceFunctor>
    00156 QFuture<ResultType> filteredReduced(const Sequence &sequence,
    00157                                     bool (C::*filter)() const,
    00158                                     ReduceFunctor reduce,
    00159                                     ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00160 {
    00161     return filteredReduced<ResultType>(sequence,
    00162                                        ConstMemberFunctionWrapper<bool, C>(filter),
    00163                                        reduce,
    00164                                        options);
    00165 }
    00166
    00167 template <typename Sequence, typename KeepFunctor, typename T, typename U, typename V>
    00168 QFuture<U> filteredReduced(const Sequence &sequence,
    00169                            KeepFunctor keep,
    00170                            T (reduce)(U &, V),
    00171                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00172 {
    00173     return filteredReduced<U>(sequence,
    00174                               keep,
    00175                               FunctionWrapper2<T, U &, V>(reduce),
    00176                               options);
    00177 }
    00178
    00179 template <typename Sequence, typename KeepFunctor, typename T, typename C, typename U>
    00180 QFuture<C> filteredReduced(const Sequence &sequence,
    00181                            KeepFunctor keep,
    00182                            T (C::*reduce)(U),
    00183                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00184 {
    00185     return filteredReduced<C>(sequence,
    00186                               keep,
    00187                               MemberFunctionWrapper1<T, C, U>(reduce),
    00188                               options);
    00189 }
    00190
    00191 template <typename Sequence, typename T, typename U, typename V, typename W>
    00192 QFuture<V> filteredReduced(const Sequence &sequence,
    00193                            bool (keep)(T),
    00194                            U (reduce)(V &, W),
    00195                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00196 {
    00197     return filteredReduced<V>(sequence,
    00198                               FunctionWrapper1<bool, T>(keep),
    00199                               FunctionWrapper2<U, V &, W>(reduce),
    00200                               options);
    00201 }
    00202
    00203 template <typename Sequence, typename C, typename T, typename U, typename V>
    00204 QFuture<U> filteredReduced(const Sequence &sequence,
    00205                            bool (C::*keep)() const,
    00206                            T (reduce)(U &, V),
    00207                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00208 {
    00209     return filteredReduced<U>(sequence,
    00210                               ConstMemberFunctionWrapper<bool, C>(keep),
    00211                               FunctionWrapper2<T, U &, V>(reduce),
    00212                               options);
    00213 }
    00214
    00215 template <typename Sequence, typename T, typename U, typename C, typename V>
    00216 QFuture<C> filteredReduced(const Sequence &sequence,
    00217                            bool (keep)(T),
    00218                            U (C::*reduce)(V),
    00219                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00220 {
    00221     return filteredReduced<C>(sequence,
    00222                               FunctionWrapper1<bool, T>(keep),
    00223                               MemberFunctionWrapper1<U, C, V>(reduce),
    00224                               options);
    00225 }
    00226
    00227 template <typename Sequence, typename C, typename T, typename D, typename U>
    00228 QFuture<D> filteredReduced(const Sequence &sequence,
    00229                            bool (C::*keep)() const,
    00230                            T (D::*reduce)(U),
    00231                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00232 {
    00233     return filteredReduced<D>(sequence,
    00234                               ConstMemberFunctionWrapper<bool, C>(keep),
    00235                               MemberFunctionWrapper1<T, D, U>(reduce),
    00236                               options);
    00237 }
    00238
    00239 // filteredReduced() on iterators
    00240 template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor>
    00241 QFuture<ResultType> filteredReduced(Iterator begin,
    00242                                     Iterator end,
    00243                                     KeepFunctor keep,
    00244                                     ReduceFunctor reduce,
    00245                                     ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00246 {
    00247    return startFilteredReduced<ResultType>(begin, end, keep, reduce, options);
    00248 }
    00249
    00250 template <typename ResultType, typename Iterator, typename T, typename ReduceFunctor>
    00251 QFuture<ResultType> filteredReduced(Iterator begin,
    00252                                     Iterator end,
    00253                                     bool (filter)(T),
    00254                                     ReduceFunctor reduce,
    00255                                     ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00256 {
    00257     return filteredReduced<ResultType>(begin,
    00258                                        end,
    00259                                        FunctionWrapper1<bool, T>(filter),
    00260                                        reduce,
    00261                                        options);
    00262 }
    00263
    00264 template <typename ResultType, typename Iterator, typename C, typename ReduceFunctor>
    00265 QFuture<ResultType> filteredReduced(Iterator begin,
    00266                                     Iterator end,
    00267                                     bool (C::*filter)() const,
    00268                                     ReduceFunctor reduce,
    00269                                     ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00270 {
    00271     return filteredReduced<ResultType>(begin,
    00272                                        end,
    00273                                        ConstMemberFunctionWrapper<bool, C>(filter),
    00274                                        reduce,
    00275                                        options);
    00276 }
    00277
    00278 template <typename Iterator, typename KeepFunctor, typename T, typename U, typename V>
    00279 QFuture<U> filteredReduced(Iterator begin,
    00280                            Iterator end,
    00281                            KeepFunctor keep,
    00282                            T (reduce)(U &, V),
    00283                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00284 {
    00285     return filteredReduced<U>(begin,
    00286                               end,
    00287                               keep,
    00288                               FunctionWrapper2<T, U &, V>(reduce),
    00289                               options);
    00290 }
    00291
    00292 template <typename Iterator, typename KeepFunctor, typename T, typename C, typename U>
    00293 QFuture<C> filteredReduced(Iterator begin,
    00294                            Iterator end,
    00295                            KeepFunctor keep,
    00296                            T (C::*reduce)(U),
    00297                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00298 {
    00299     return filteredReduced<C>(begin,
    00300                               end,
    00301                               keep,
    00302                               MemberFunctionWrapper1<T, C, U>(reduce),
    00303                               options);
    00304 }
    00305
    00306 template <typename Iterator, typename T, typename U, typename V, typename W>
    00307 QFuture<V> filteredReduced(Iterator begin,
    00308                            Iterator end,
    00309                            bool (keep)(T),
    00310                            U (reduce)(V &, W),
    00311                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00312 {
    00313     return filteredReduced<V>(begin,
    00314                               end,
    00315                               FunctionWrapper1<bool, T>(keep),
    00316                               FunctionWrapper2<U, V &, W>(reduce),
    00317                               options);
    00318 }
    00319
    00320 template <typename Iterator, typename C, typename T, typename U, typename V>
    00321 QFuture<U> filteredReduced(Iterator begin,
    00322                            Iterator end,
    00323                            bool (C::*keep)() const,
    00324                            T (reduce)(U &, V),
    00325                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00326 {
    00327     return filteredReduced<U>(begin,
    00328                               end,
    00329                               ConstMemberFunctionWrapper<bool, C>(keep),
    00330                               FunctionWrapper2<T, U &, V>(reduce),
    00331                               options);
    00332 }
    00333
    00334 template <typename Iterator, typename T, typename U, typename C, typename V>
    00335 QFuture<C> filteredReduced(Iterator begin,
    00336                            Iterator end,
    00337                            bool (keep)(T),
    00338                            U (C::*reduce)(V),
    00339                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00340 {
    00341     return filteredReduced<C>(begin,
    00342                               end,
    00343                               FunctionWrapper1<bool, T>(keep),
    00344                               MemberFunctionWrapper1<U, C, V>(reduce),
    00345                               options);
    00346 }
    00347
    00348 template <typename Iterator, typename C, typename T, typename D, typename U>
    00349 QFuture<D> filteredReduced(Iterator begin,
    00350                            Iterator end,
    00351                            bool (C::*keep)() const,
    00352                            T (D::*reduce)(U),
    00353                            ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00354 {
    00355     return filteredReduced<D>(begin,
    00356                               end,
    00357                               ConstMemberFunctionWrapper<bool, C>(keep),
    00358                               MemberFunctionWrapper1<T, D, U>(reduce),
    00359                               options);
    00360 }
    00361
    00362
    00363 // filtered() on sequences
    00364 template <typename Sequence, typename KeepFunctor>
    00365 QFuture<typename Sequence::value_type> filtered(const Sequence &sequence, KeepFunctor keep)
    00366 {
    00367     return startFiltered(sequence, keep);
    00368 }
    00369
    00370 template <typename Sequence, typename T>
    00371 QFuture<typename Sequence::value_type> filtered(const Sequence &sequence, bool (keep)(T))
    00372 {
    00373     return startFiltered(sequence, FunctionWrapper1<bool, T>(keep));
    00374 }
    00375
    00376 template <typename Sequence, typename C>
    00377 QFuture<typename Sequence::value_type> filtered(const Sequence &sequence, bool (C::*keep)() const)
    00378 {
    00379     return startFiltered(sequence, ConstMemberFunctionWrapper<bool, C>(keep));
    00380 }
    00381
    00382 // filtered() on iterators
    00383 template <typename Iterator, typename KeepFunctor>
    00384 QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin, Iterator end, KeepFunctor keep)
    00385 {
    00386     return startFiltered(begin, end, keep);
    00387 }
    00388
    00389 template <typename Iterator, typename T>
    00390 QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin, Iterator end, bool (keep)(T))
    00391 {
    00392     return startFiltered(begin, end, FunctionWrapper1<bool, T>(keep));
    00393 }
    00394
    00395 template <typename Iterator, typename C>
    00396 QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin,
    00397                                                 Iterator end,
    00398                                                 bool (C::*keep)() const)
    00399 {
    00400     return startFiltered(begin, end, ConstMemberFunctionWrapper<bool, C>(keep));
    00401 }
    00402
    00403
    00404 // blocking filter() on sequences
    00405 template <typename Sequence, typename KeepFunctor>
    00406 void blockingFilter(Sequence &sequence, KeepFunctor keep)
    00407 {
    00408     filterInternal(sequence, keep, &Sequence::push_back).startBlocking();
    00409 }
    00410
    00411 template <typename Sequence, typename T>
    00412 void blockingFilter(Sequence &sequence, bool (keep)(T))
    00413 {
    00414     filterInternal(sequence, FunctionWrapper1<bool, T>(keep), &Sequence::push_back)
    00415         .startBlocking();
    00416 }
    00417
    00418 template <typename Sequence, typename C>
    00419 void blockingFilter(Sequence &sequence, bool (C::*keep)() const)
    00420 {
    00421     filterInternal(sequence,
    00422                    ConstMemberFunctionWrapper<bool, C>(keep),
    00423                    &Sequence::push_back)
    00424         .startBlocking();
    00425 }
    00426
    00427 // blocking filteredReduced() on sequences
    00428 template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
    00429 ResultType blockingFilteredReduced(const Sequence &sequence,
    00430                                    KeepFunctor keep,
    00431                                    ReduceFunctor reduce,
    00432                                    ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00433 {
    00434     return startFilteredReduced<ResultType>(sequence, keep, reduce, options)
    00435         .startBlocking();
    00436 }
    00437
    00438 template <typename ResultType, typename Sequence, typename T, typename ReduceFunctor>
    00439 ResultType blockingFilteredReduced(const Sequence &sequence,
    00440                                    bool (filter)(T),
    00441                                    ReduceFunctor reduce,
    00442                                    ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00443 {
    00444     return blockingFilteredReduced<ResultType>
    00445         (sequence,
    00446          FunctionWrapper1<bool, T>(filter),
    00447          reduce,
    00448          options);
    00449 }
    00450
    00451 template <typename ResultType, typename Sequence, typename C, typename ReduceFunctor>
    00452 ResultType blockingFilteredReduced(const Sequence &sequence,
    00453                                    bool (C::*filter)() const,
    00454                                    ReduceFunctor reduce,
    00455                                    ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00456 {
    00457     return blockingFilteredReduced<ResultType>
    00458         (sequence,
    00459          ConstMemberFunctionWrapper<bool, C>(filter),
    00460          reduce,
    00461          options);
    00462 }
    00463
    00464 template <typename Sequence, typename KeepFunctor, typename T, typename U, typename V>
    00465 U blockingFilteredReduced(const Sequence &sequence,
    00466                           KeepFunctor keep,
    00467                           T (reduce)(U &, V),
    00468                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00469 {
    00470     return blockingFilteredReduced<U>
    00471         (sequence,
    00472          keep,
    00473          FunctionWrapper2<T, U &, V>(reduce),
    00474          options);
    00475 }
    00476
    00477 template <typename Sequence, typename KeepFunctor, typename T, typename C, typename U>
    00478 C blockingFilteredReduced(const Sequence &sequence,
    00479                           KeepFunctor keep,
    00480                           T (C::*reduce)(U),
    00481                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00482 {
    00483     return blockingFilteredReduced<C>
    00484         (sequence,
    00485          keep,
    00486          MemberFunctionWrapper1<T, C, U>(reduce),
    00487          options);
    00488 }
    00489
    00490 template <typename Sequence, typename T, typename U, typename V, typename W>
    00491 V blockingFilteredReduced(const Sequence &sequence,
    00492                           bool (keep)(T),
    00493                           U (reduce)(V &, W),
    00494                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00495 {
    00496     return blockingFilteredReduced<V>
    00497         (sequence,
    00498          FunctionWrapper1<bool, T>(keep),
    00499          FunctionWrapper2<U, V &, W>(reduce),
    00500          options);
    00501 }
    00502
    00503 template <typename Sequence, typename C, typename T, typename U, typename V>
    00504 U blockingFilteredReduced(const Sequence &sequence,
    00505                           bool (C::*keep)() const,
    00506                           T (reduce)(U &, V),
    00507                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00508 {
    00509     return blockingFilteredReduced<U>
    00510         (sequence,
    00511          ConstMemberFunctionWrapper<bool, C>(keep),
    00512          FunctionWrapper2<T, U &, V>(reduce),
    00513          options);
    00514 }
    00515
    00516 template <typename Sequence, typename T, typename U, typename C, typename V>
    00517 C blockingFilteredReduced(const Sequence &sequence,
    00518                           bool (keep)(T),
    00519                           U (C::*reduce)(V),
    00520                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00521 {
    00522     return blockingFilteredReduced<C>
    00523         (sequence,
    00524          FunctionWrapper1<bool, T>(keep),
    00525          MemberFunctionWrapper1<U, C, V>(reduce),
    00526          options);
    00527 }
    00528
    00529 template <typename Sequence, typename C, typename T, typename D, typename U>
    00530 D blockingFilteredReduced(const Sequence &sequence,
    00531                           bool (C::*keep)() const,
    00532                           T (D::*reduce)(U),
    00533                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00534 {
    00535     return blockingFilteredReduced<D>
    00536         (sequence,
    00537          ConstMemberFunctionWrapper<bool, C>(keep),
    00538          MemberFunctionWrapper1<T, D, U>(reduce),
    00539          options);
    00540 }
    00541
    00542 // blocking filteredReduced() on iterators
    00543 template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor>
    00544 ResultType blockingFilteredReduced(Iterator begin,
    00545                                    Iterator end,
    00546                                    KeepFunctor keep,
    00547                                    ReduceFunctor reduce,
    00548                                    ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00549 {
    00550     return startFilteredReduced<ResultType>(begin, end, keep, reduce, options)
    00551         .startBlocking();
    00552 }
    00553
    00554 template <typename ResultType, typename Iterator, typename T, typename ReduceFunctor>
    00555 ResultType blockingFilteredReduced(Iterator begin,
    00556                                    Iterator end,
    00557                                    bool (filter)(T),
    00558                                    ReduceFunctor reduce,
    00559                                    ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00560 {
    00561     return blockingFilteredReduced<ResultType>
    00562         (begin,
    00563          end,
    00564          FunctionWrapper1<bool, T>(filter),
    00565          reduce,
    00566          options);
    00567 }
    00568
    00569 template <typename ResultType, typename Iterator, typename C, typename ReduceFunctor>
    00570 ResultType blockingFilteredReduced(Iterator begin,
    00571                                    Iterator end,
    00572                                    bool (C::*filter)() const,
    00573                                    ReduceFunctor reduce,
    00574                                    ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00575 {
    00576     return blockingFilteredReduced<ResultType>
    00577         (begin,
    00578          end,
    00579          ConstMemberFunctionWrapper<bool, C>(filter),
    00580          reduce,
    00581          options);
    00582 }
    00583
    00584 template <typename Iterator, typename KeepFunctor, typename T, typename U, typename V>
    00585 U blockingFilteredReduced(Iterator begin,
    00586                           Iterator end,
    00587                           KeepFunctor keep,
    00588                           T (reduce)(U &, V),
    00589                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00590 {
    00591     return blockingFilteredReduced<U>
    00592         (begin,
    00593          end,
    00594          keep,
    00595          FunctionWrapper2<T, U &, V>(reduce),
    00596          options);
    00597 }
    00598
    00599 template <typename Iterator, typename KeepFunctor, typename T, typename C, typename U>
    00600 C blockingFilteredReduced(Iterator begin,
    00601                           Iterator end,
    00602                           KeepFunctor keep,
    00603                           T (C::*reduce)(U),
    00604                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00605 {
    00606     return blockingFilteredReduced<C>
    00607         (begin,
    00608          end,
    00609          keep,
    00610          MemberFunctionWrapper1<T, C, U>(reduce),
    00611          options);
    00612 }
    00613
    00614 template <typename Iterator, typename T, typename U, typename V, typename W>
    00615 V blockingFilteredReduced(Iterator begin,
    00616                           Iterator end,
    00617                           bool (keep)(T),
    00618                           U (reduce)(V &, W),
    00619                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00620 {
    00621     return blockingFilteredReduced<V>
    00622         (begin,
    00623          end,
    00624          FunctionWrapper1<bool, T>(keep),
    00625          FunctionWrapper2<U, V &, W>(reduce),
    00626          options);
    00627 }
    00628
    00629 template <typename Iterator, typename C, typename T, typename U, typename V>
    00630 U blockingFilteredReduced(Iterator begin,
    00631                           Iterator end,
    00632                           bool (C::*keep)() const,
    00633                           T (reduce)(U &, V),
    00634                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00635 {
    00636     return blockingFilteredReduced<U>
    00637         (begin,
    00638          end,
    00639          ConstMemberFunctionWrapper<bool, C>(keep),
    00640          FunctionWrapper2<T, U &, V>(reduce),
    00641          options);
    00642 }
    00643
    00644 template <typename Iterator, typename T, typename U, typename C, typename V>
    00645 C blockingFilteredReduced(Iterator begin,
    00646                           Iterator end,
    00647                           bool (keep)(T),
    00648                           U (C::*reduce)(V),
    00649                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00650 {
    00651     return blockingFilteredReduced<C>
    00652         (begin,
    00653          end,
    00654          FunctionWrapper1<bool, T>(keep),
    00655          MemberFunctionWrapper1<U, C, V>(reduce),
    00656          options);
    00657 }
    00658
    00659 template <typename Iterator, typename C, typename T, typename D, typename U>
    00660 D blockingFilteredReduced(Iterator begin,
    00661                           Iterator end,
    00662                           bool (C::*keep)() const,
    00663                           T (D::*reduce)(U),
    00664                           ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce))
    00665 {
    00666     return blockingFilteredReduced<D>
    00667         (begin,
    00668          end,
    00669          ConstMemberFunctionWrapper<bool, C>(keep),
    00670          MemberFunctionWrapper1<T, D, U>(reduce),
    00671          options);
    00672 }
    00673
    00674 // blocking filtered() on sequences
    00675 template <typename Sequence, typename KeepFunctor>
    00676 Sequence blockingFiltered(const Sequence &sequence, KeepFunctor keep)
    00677 {
    00678     return blockingFilteredReduced(sequence, keep, &Sequence::push_back, OrderedReduce);
    00679 }
    00680
    00681 template <typename Sequence, typename T>
    00682 Sequence blockingFiltered(const Sequence &sequence, bool (keep)(T))
    00683 {
    00684     return blockingFilteredReduced(sequence, keep, &Sequence::push_back, OrderedReduce);
    00685 }
    00686
    00687 template <typename Sequence, typename C>
    00688 Sequence blockingFiltered(const Sequence &sequence, bool (C::*filter)() const)
    00689 {
    00690     return blockingFilteredReduced(sequence,
    00691                                    filter,
    00692                                    &Sequence::push_back,
    00693                                    OrderedReduce);
    00694 }
    00695
    00696 // blocking filtered() on iterators
    00697 template <typename OutputSequence, typename Iterator, typename KeepFunctor>
    00698 OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor keep)
    00699 {
    00700     return blockingFilteredReduced(begin,
    00701                                    end,
    00702                                    keep,
    00703                                    &OutputSequence::push_back,
    00704                                    OrderedReduce);
    00705 }
    00706
    00707 template <typename OutputSequence, typename Iterator, typename T>
    00708 OutputSequence blockingFiltered(Iterator begin, Iterator end, bool (keep)(T))
    00709 {
    00710     return blockingFilteredReduced(begin,
    00711                                    end,
    00712                                    keep,
    00713                                    &OutputSequence::push_back,
    00714                                    OrderedReduce);
    00715 }
    00716
    00717 template <typename OutputSequence, typename Iterator, typename C>
    00718 OutputSequence blockingFiltered(Iterator begin, Iterator end, bool (C::*filter)() const)
    00719 {
    00720     return blockingFilteredReduced(begin,
    00721                                    end,
    00722                                    filter,
    00723                                    &OutputSequence::push_back,
    00724                                    OrderedReduce);
    00725 }
    00726
    00727 } // namespace QtConcurrent
    00728
    00729 #endif // qdoc
    00730
    00731 QT_END_NAMESPACE
    00732 QT_END_HEADER
    00733
    00734 #endif // QT_NO_CONCURRENT
    00735
    00736 #endif