3
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /fasttmp/mkdist-qt-4.5.2-1245473805/qt-x11-opensource-src-4.5.2/src/corelib/concurrent/qtconcurrentfilter.cpp -->
5
<!-- qtconcurrentfilter.cpp -->
7
<title>Qt 4.5: <QtConcurrentFilter> - Concurrent Filter and Filter-Reduce</title>
7
<title>Qt 4.6: <QtConcurrentFilter> - Concurrent Filter and Filter-Reduce</title>
8
8
<link href="classic.css" rel="stylesheet" type="text/css" />
11
11
<table border="0" cellpadding="0" cellspacing="0" width="100%">
13
<td align="left" valign="top" width="32"><a href="http://qtsoftware.com/products/qt"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
14
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="namespaces.html"><font color="#004faf">All Namespaces</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
15
<td align="right" valign="top" width="230"></td></tr></table><h1 class="title"><QtConcurrentFilter> - Concurrent Filter and Filter-Reduce<br /><span class="subtitle"></span>
13
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
14
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td><td class="searchBar" align="right" valign="center"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="000136343326384750312:dhbxnqlakyu" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="31" /><input type="submit" name="sa" value="Search" /></div></form></td>
15
</tr></table><h1 class="title"><QtConcurrentFilter> - Concurrent Filter and Filter-Reduce<br /><span class="subtitle"></span>
17
17
<p>The <QtConcurrentFilter> header provides concurrent Filter and Filter-Reduce. <a href="#details">More...</a></p>
20
20
<a name="Functionsx"></a>
23
<li><div class="fn"></div>QFuture<void> <b><a href="qtconcurrentfilter.html#filter">filter</a></b> ( Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</li>
24
<li><div class="fn"></div>QFuture<T> <b><a href="qtconcurrentfilter.html#filtered">filtered</a></b> ( const Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</li>
25
<li><div class="fn"></div>QFuture<T> <b><a href="qtconcurrentfilter.html#filtered-2">filtered</a></b> ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, FilterFunction <i>filterFunction</i> )</li>
26
<li><div class="fn"></div>QFuture<T> <b><a href="qtconcurrentfilter.html#filteredReduced">filteredReduced</a></b> ( const Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i>, ReduceFunction <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</li>
27
<li><div class="fn"></div>QFuture<T> <b><a href="qtconcurrentfilter.html#filteredReduced-2">filteredReduced</a></b> ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, FilterFunction <i>filterFunction</i>, ReduceFunction <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</li>
29
<p>These functions are a part of the <a href="threads.html#qtconcurrent-intro">Qt Concurrent</a> framework.</p>
22
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
23
<tr><td class="memItemLeft" align="right" valign="top">QFuture<void> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentfilter.html#filter">filter</a></b> ( Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</td></tr>
24
<tr><td class="memItemLeft" align="right" valign="top">QFuture<T> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentfilter.html#filtered">filtered</a></b> ( const Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</td></tr>
25
<tr><td class="memItemLeft" align="right" valign="top">QFuture<T> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentfilter.html#filtered-2">filtered</a></b> ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, FilterFunction <i>filterFunction</i> )</td></tr>
26
<tr><td class="memItemLeft" align="right" valign="top">QFuture<T> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentfilter.html#filteredReduced">filteredReduced</a></b> ( const Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i>, ReduceFunction <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</td></tr>
27
<tr><td class="memItemLeft" align="right" valign="top">QFuture<T> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentfilter.html#filteredReduced-2">filteredReduced</a></b> ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, FilterFunction <i>filterFunction</i>, ReduceFunction <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</td></tr>
29
<p>These functions are a part of the <a href="threads-qtconcurrent.html">Qt Concurrent</a> framework.</p>
30
30
<p>The <a href="qtconcurrentfilter.html#filter">QtConcurrent::filter</a>(), <a href="qtconcurrentfilter.html#filtered">QtConcurrent::filtered</a>() and <a href="qtconcurrentfilter.html#filteredReduced">QtConcurrent::filteredReduced</a>() functions filter items in a sequence such as a <a href="qlist.html">QList</a> or a <a href="qvector.html">QVector</a> in parallel. <a href="qtconcurrentfilter.html#filter">QtConcurrent::filter</a>() modifies a sequence in-place, <a href="qtconcurrentfilter.html#filtered">QtConcurrent::filtered</a>() returns a new sequence containing the filtered content, and <a href="qtconcurrentfilter.html#filteredReduced">QtConcurrent::filteredReduced</a>() returns a single result.</p>
31
31
<p>Each of the above functions have a blocking variant that returns the final result instead of a <a href="qfuture.html">QFuture</a>. You use them in the same way as the asynchronous variants.</p>
32
32
<pre> QStringList strings = ...;
145
145
boost::bind(static_cast<bool(QString::*)(const QRegExp&)>( &QString::contains ), QRegExp("..." ));</pre>
147
147
<h2>Function Documentation</h2>
148
<a name="//apple_ref/cpp/instm/QtConcurrent/filter" />
148
149
<h3 class="fn"><a name="filter"></a><a href="qfuture.html">QFuture</a><void> QtConcurrent::filter ( Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</h3>
149
150
<p>Calls <i>filterFunction</i> once for each item in <i>sequence</i>. If <i>filterFunction</i> returns true, the item is kept in <i>sequence</i>; otherwise, the item is removed from <i>sequence</i>.</p>
151
<a name="//apple_ref/cpp/instm/QtConcurrent/filtered" />
150
152
<h3 class="fn"><a name="filtered"></a><a href="qfuture.html">QFuture</a><T> QtConcurrent::filtered ( const Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</h3>
151
153
<p>Calls <i>filterFunction</i> once for each item in <i>sequence</i> and returns a new Sequence of kept items. If <i>filterFunction</i> returns true, a copy of the item is put in the new Sequence. Otherwise, the item will <i>not</i> appear in the new Sequence.</p>
152
154
<h3 class="fn"><a name="filtered-2"></a><a href="qfuture.html">QFuture</a><T> QtConcurrent::filtered ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, FilterFunction <i>filterFunction</i> )</h3>
153
155
<p>Calls <i>filterFunction</i> once for each item from <i>begin</i> to <i>end</i> and returns a new Sequence of kept items. If <i>filterFunction</i> returns true, a copy of the item is put in the new Sequence. Otherwise, the item will <i>not</i> appear in the new Sequence.</p>
156
<a name="//apple_ref/cpp/instm/QtConcurrent/filteredReduced" />
154
157
<h3 class="fn"><a name="filteredReduced"></a><a href="qfuture.html">QFuture</a><T> QtConcurrent::filteredReduced ( const Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i>, ReduceFunction <i>reduceFunction</i>, <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a> <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</h3>
155
158
<p>Calls <i>filterFunction</i> once for each item in <i>sequence</i>. If <i>filterFunction</i> returns true for an item, that item is then passed to <i>reduceFunction</i>. In other words, the return value is the result of <i>reduceFunction</i> for each item where <i>filterFunction</i> returns true.</p>
156
159
<p>Note that while <i>filterFunction</i> is called concurrently, only one thread at a time will call <i>reduceFunction</i>. The order in which <i>reduceFunction</i> is called is undefined if <i>reduceOptions</i> is <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::UnorderedReduce</a>. If <i>reduceOptions</i> is <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::OrderedReduce</a>, <i>reduceFunction</i> is called in the order of the original sequence.</p>
159
162
<p>Note that while <i>filterFunction</i> is called concurrently, only one thread at a time will call <i>reduceFunction</i>. The order in which <i>reduceFunction</i> is called is undefined if <i>reduceOptions</i> is <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::UnorderedReduce</a>. If <i>reduceOptions</i> is <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::OrderedReduce</a>, the <i>reduceFunction</i> is called in the order of the original sequence.</p>
160
163
<p /><address><hr /><div align="center">
161
164
<table width="100%" cellspacing="0" border="0"><tr class="address">
162
<td width="30%" align="left">Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
163
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
164
<td width="30%" align="right"><div align="right">Qt 4.5.2</div></td>
165
</tr></table></div></address></body>
165
<td width="40%" align="left">Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
166
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
167
<td width="40%" align="right"><div align="right">Qt 4.6.0</div></td>
168
<script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script><script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en"></script><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></tr></table></div></address></body>