<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- qtconcurrentmap.cpp --> <head> <title>Qt 4.6: QtConcurrent Namespace Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <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> <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></tr></table><h1 class="title">QtConcurrent Namespace Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span> </h1> <p>The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives. <a href="#details">More...</a></p> <pre> #include <<a href="qtcore.html">QtCore</a>></pre><p>This namespace was introduced in Qt 4.4.</p> <ul> </ul> <hr /> <a name="classes"></a> <h2>Classes</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent-exception.html">Exception</a></b></td></tr> <tr><td class="memItemLeft" align="right" valign="top">class </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent-unhandledexception.html">UnhandledException</a></b></td></tr> </table> <hr /> <a name="types"></a> <h2>Types</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#ReduceOption-enum">ReduceOption</a></b> { UnorderedReduce, OrderedReduce, SequentialReduce }</td></tr> <tr><td class="memItemLeft" align="right" valign="top">flags </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#ReduceOption-enum">ReduceOptions</a></b></td></tr> </table> <hr /> <a name="functions"></a> <h2>Functions</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#blockingFilter">blockingFilter</a></b> ( Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">Sequence </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#blockingFiltered">blockingFiltered</a></b> ( const Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">Sequence </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#blockingFiltered-2">blockingFiltered</a></b> ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, FilterFunction <i>filterFunction</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#blockingFilteredReduced">blockingFilteredReduced</a></b> ( const Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i>, ReduceFunction <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#blockingFilteredReduced-2">blockingFilteredReduced</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> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#blockingMap">blockingMap</a></b> ( Sequence & <i>sequence</i>, MapFunction <i>function</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#blockingMap-2">blockingMap</a></b> ( Iterator <i>begin</i>, Iterator <i>end</i>, MapFunction <i>function</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#blockingMapped">blockingMapped</a></b> ( const Sequence & <i>sequence</i>, MapFunction <i>function</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrent.html#blockingMapped-2">blockingMapped</a></b> ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, MapFunction <i>function</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentmap.html#blockingMappedReduced">blockingMappedReduced</a></b> ( const Sequence & <i>sequence</i>, MapFunction <i>mapFunction</i>, ReduceFunction <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentmap.html#blockingMappedReduced-2">blockingMappedReduced</a></b> ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, MapFunction <i>mapFunction</i>, ReduceFunction <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</td></tr> <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> <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> <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> <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> <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> <tr><td class="memItemLeft" align="right" valign="top">QFuture<void> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentmap.html#map">map</a></b> ( Sequence & <i>sequence</i>, MapFunction <i>function</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QFuture<void> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentmap.html#map-2">map</a></b> ( Iterator <i>begin</i>, Iterator <i>end</i>, MapFunction <i>function</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QFuture<T> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentmap.html#mapped">mapped</a></b> ( const Sequence & <i>sequence</i>, MapFunction <i>function</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QFuture<T> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentmap.html#mapped-2">mapped</a></b> ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, MapFunction <i>function</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QFuture<T> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentmap.html#mappedReduced">mappedReduced</a></b> ( const Sequence & <i>sequence</i>, MapFunction <i>mapFunction</i>, ReduceFunction <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QFuture<T> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentmap.html#mappedReduced-2">mappedReduced</a></b> ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, MapFunction <i>mapFunction</i>, ReduceFunction <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QFuture<T> </td><td class="memItemRight" valign="bottom"><b><a href="qtconcurrentrun.html#run">run</a></b> ( Function <i>function</i>, ... )</td></tr> </table> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives.</p> <p>See the <a href="threads-qtconcurrent.html">Qt Concurrent</a> chapter in the <a href="threads.html">threading</a> documentation.</p> <hr /> <h2>Classes</h2> <h3> class <a href="qtconcurrent-exception.html">Exception</a></h3><p>The Exception class provides a base class for exceptions that can transferred across threads. <a href="qtconcurrent-exception.html#details">More...</a></p> <h3> class <a href="qtconcurrent-unhandledexception.html">UnhandledException</a></h3><p>The UnhandledException class represents an unhandled exception in a worker thread. <a href="qtconcurrent-unhandledexception.html#details">More...</a></p> <hr /> <h2>Type Documentation</h2> <a name="//apple_ref/cpp/tag/QtConcurrent/ReduceOption"></a> <a name="//apple_ref/cpp/econst/QtConcurrent/UnorderedReduce"></a> <a name="//apple_ref/cpp/econst/QtConcurrent/OrderedReduce"></a> <a name="//apple_ref/cpp/econst/QtConcurrent/SequentialReduce"></a> <a name="//apple_ref/cpp/tdef/QtConcurrent/ReduceOptions"></a> <h3 class="flags"><a name="ReduceOption-enum"></a>enum QtConcurrent::ReduceOption<br />flags QtConcurrent::ReduceOptions</h3> <p>This enum specifies the order of which results from the map or filter function are passed to the reduce function.</p> <p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%"> <tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr> <tr><td valign="top"><tt>QtConcurrent::UnorderedReduce</tt></td><td align="center" valign="top"><tt>0x1</tt></td><td valign="top">Reduction is done in an arbitrary order.</td></tr> <tr><td valign="top"><tt>QtConcurrent::OrderedReduce</tt></td><td align="center" valign="top"><tt>0x2</tt></td><td valign="top">Reduction is done in the order of the original sequence.</td></tr> <tr><td valign="top"><tt>QtConcurrent::SequentialReduce</tt></td><td align="center" valign="top"><tt>0x4</tt></td><td valign="top">Reduction is done sequentally: only one thread will enter the reduce function at a time. (Parallel reduction might be supported in a future version of Qt Concurrent.)</td></tr> </table></p> <p>The ReduceOptions type is a typedef for <a href="qflags.html">QFlags</a><ReduceOption>. It stores an OR combination of ReduceOption values.</p> <hr /> <h2>Function Documentation</h2> <a name="//apple_ref/cpp/instm/QtConcurrent/blockingFilter"></a> <h3 class="fn"><a name="blockingFilter"></a>void QtConcurrent::blockingFilter ( Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</h3> <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> <p><b>Note:</b> This function will block until all items in the sequence have been processed.</p> <a name="//apple_ref/cpp/instm/QtConcurrent/blockingFiltered"></a> <h3 class="fn"><a name="blockingFiltered"></a>Sequence QtConcurrent::blockingFiltered ( const Sequence & <i>sequence</i>, FilterFunction <i>filterFunction</i> )</h3> <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> <p><b>Note:</b> This function will block until all items in the sequence have been processed.</p> <p>See also <a href="qtconcurrentfilter.html#filtered">filtered</a>().</p> <h3 class="fn"><a name="blockingFiltered-2"></a>Sequence QtConcurrent::blockingFiltered ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, FilterFunction <i>filterFunction</i> )</h3> <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> <p><b>Note:</b> This function will block until the iterator reaches the end of the sequence being processed.</p> <p>See also <a href="qtconcurrentfilter.html#filtered">filtered</a>().</p> <a name="//apple_ref/cpp/instm/QtConcurrent/blockingFilteredReduced"></a> <h3 class="fn"><a name="blockingFilteredReduced"></a>T QtConcurrent::blockingFilteredReduced ( 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> <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> <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> <p><b>Note:</b> This function will block until all items in the sequence have been processed.</p> <p>See also <a href="qtconcurrentfilter.html#filteredReduced">filteredReduced</a>().</p> <h3 class="fn"><a name="blockingFilteredReduced-2"></a>T QtConcurrent::blockingFilteredReduced ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, FilterFunction <i>filterFunction</i>, ReduceFunction <i>reduceFunction</i>, <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a> <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</h3> <p>Calls <i>filterFunction</i> once for each item from <i>begin</i> to <i>end</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> <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> <p><b>Note:</b> This function will block until the iterator reaches the end of the sequence being processed.</p> <p>See also <a href="qtconcurrentfilter.html#filteredReduced">filteredReduced</a>().</p> <a name="//apple_ref/cpp/instm/QtConcurrent/blockingMap"></a> <h3 class="fn"><a name="blockingMap"></a>void QtConcurrent::blockingMap ( Sequence & <i>sequence</i>, MapFunction <i>function</i> )</h3> <p>Calls <i>function</i> once for each item in <i>sequence</i>. The <i>function</i> is passed a reference to the item, so that any modifications done to the item will appear in <i>sequence</i>.</p> <p><b>Note:</b> This function will block until all items in the sequence have been processed.</p> <p>See also <a href="qtconcurrentmap.html#map">map</a>().</p> <h3 class="fn"><a name="blockingMap-2"></a>void QtConcurrent::blockingMap ( Iterator <i>begin</i>, Iterator <i>end</i>, MapFunction <i>function</i> )</h3> <p>Calls <i>function</i> once for each item from <i>begin</i> to <i>end</i>. The <i>function</i> is passed a reference to the item, so that any modifications done to the item will appear in the sequence which the iterators belong to.</p> <p><b>Note:</b> This function will block until the iterator reaches the end of the sequence being processed.</p> <p>See also <a href="qtconcurrentmap.html#map">map</a>().</p> <a name="//apple_ref/cpp/instm/QtConcurrent/blockingMapped"></a> <h3 class="fn"><a name="blockingMapped"></a>T QtConcurrent::blockingMapped ( const Sequence & <i>sequence</i>, MapFunction <i>function</i> )</h3> <p>Calls <i>function</i> once for each item in <i>sequence</i> and returns a Sequence containing the results. The type of the results will match the type returned my the MapFunction.</p> <p><b>Note:</b> This function will block until all items in the sequence have been processed.</p> <p>See also <a href="qtconcurrentmap.html#mapped">mapped</a>().</p> <h3 class="fn"><a name="blockingMapped-2"></a>T QtConcurrent::blockingMapped ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, MapFunction <i>function</i> )</h3> <p>Calls <i>function</i> once for each item from <i>begin</i> to <i>end</i> and returns a container with the results. Specify the type of container as the a template argument, like this:</p> <pre> QList<int> ints = QtConcurrent::blockingMapped<QList<int> >(beginIterator, endIterator, fn);</pre> <p><b>Note:</b> This function will block until the iterator reaches the end of the sequence being processed.</p> <p>See also <a href="qtconcurrentmap.html#mapped">mapped</a>().</p> <a name="//apple_ref/cpp/instm/QtConcurrent/blockingMappedReduced"></a> <h3 class="fn"><a name="blockingMappedReduced"></a>T QtConcurrent::blockingMappedReduced ( const Sequence & <i>sequence</i>, MapFunction <i>mapFunction</i>, ReduceFunction <i>reduceFunction</i>, <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a> <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</h3> <p>Calls <i>mapFunction</i> once for each item in <i>sequence</i>. The return value of each <i>mapFunction</i> is passed to <i>reduceFunction</i>.</p> <p>Note that while <i>mapFunction</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 determined by <i>reduceOptions</i>.</p> <p><b>Note:</b> This function will block until all items in the sequence have been processed.</p> <p>See also <a href="qtconcurrentmap.html#mapped">mapped</a>().</p> <h3 class="fn"><a name="blockingMappedReduced-2"></a>T QtConcurrent::blockingMappedReduced ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, MapFunction <i>mapFunction</i>, ReduceFunction <i>reduceFunction</i>, <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a> <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</h3> <p>Calls <i>mapFunction</i> once for each item from <i>begin</i> to <i>end</i>. The return value of each <i>mapFunction</i> is passed to <i>reduceFunction</i>.</p> <p>Note that while <i>mapFunction</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.</p> <p><b>Note:</b> This function will block until the iterator reaches the end of the sequence being processed.</p> <p>See also <a href="qtconcurrentmap.html#blockingMappedReduced">blockingMappedReduced</a>().</p> <a name="//apple_ref/cpp/instm/QtConcurrent/filter"></a> <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> <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> <a name="//apple_ref/cpp/instm/QtConcurrent/filtered"></a> <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> <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> <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> <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> <a name="//apple_ref/cpp/instm/QtConcurrent/filteredReduced"></a> <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> <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> <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> <h3 class="fn"><a name="filteredReduced-2"></a><a href="qfuture.html">QFuture</a><T> QtConcurrent::filteredReduced ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, FilterFunction <i>filterFunction</i>, ReduceFunction <i>reduceFunction</i>, <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a> <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</h3> <p>Calls <i>filterFunction</i> once for each item from <i>begin</i> to <i>end</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> <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> <a name="//apple_ref/cpp/instm/QtConcurrent/map"></a> <h3 class="fn"><a name="map"></a><a href="qfuture.html">QFuture</a><void> QtConcurrent::map ( Sequence & <i>sequence</i>, MapFunction <i>function</i> )</h3> <p>Calls <i>function</i> once for each item in <i>sequence</i>. The <i>function</i> is passed a reference to the item, so that any modifications done to the item will appear in <i>sequence</i>.</p> <h3 class="fn"><a name="map-2"></a><a href="qfuture.html">QFuture</a><void> QtConcurrent::map ( Iterator <i>begin</i>, Iterator <i>end</i>, MapFunction <i>function</i> )</h3> <p>Calls <i>function</i> once for each item from <i>begin</i> to <i>end</i>. The <i>function</i> is passed a reference to the item, so that any modifications done to the item will appear in the sequence which the iterators belong to.</p> <a name="//apple_ref/cpp/instm/QtConcurrent/mapped"></a> <h3 class="fn"><a name="mapped"></a><a href="qfuture.html">QFuture</a><T> QtConcurrent::mapped ( const Sequence & <i>sequence</i>, MapFunction <i>function</i> )</h3> <p>Calls <i>function</i> once for each item in <i>sequence</i> and returns a future with each mapped item as a result. You can use <a href="qfuture-const-iterator.html">QFuture::const_iterator</a> or <a href="qfutureiterator.html">QFutureIterator</a> to iterate through the results.</p> <h3 class="fn"><a name="mapped-2"></a><a href="qfuture.html">QFuture</a><T> QtConcurrent::mapped ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, MapFunction <i>function</i> )</h3> <p>Calls <i>function</i> once for each item from <i>begin</i> to <i>end</i> and returns a future with each mapped item as a result. You can use <a href="qfuture-const-iterator.html">QFuture::const_iterator</a> or <a href="qfutureiterator.html">QFutureIterator</a> to iterate through the results.</p> <a name="//apple_ref/cpp/instm/QtConcurrent/mappedReduced"></a> <h3 class="fn"><a name="mappedReduced"></a><a href="qfuture.html">QFuture</a><T> QtConcurrent::mappedReduced ( const Sequence & <i>sequence</i>, MapFunction <i>mapFunction</i>, ReduceFunction <i>reduceFunction</i>, <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a> <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</h3> <p>Calls <i>mapFunction</i> once for each item in <i>sequence</i>. The return value of each <i>mapFunction</i> is passed to <i>reduceFunction</i>.</p> <p>Note that while <i>mapFunction</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 determined by <i>reduceOptions</i>.</p> <h3 class="fn"><a name="mappedReduced-2"></a><a href="qfuture.html">QFuture</a><T> QtConcurrent::mappedReduced ( ConstIterator <i>begin</i>, ConstIterator <i>end</i>, MapFunction <i>mapFunction</i>, ReduceFunction <i>reduceFunction</i>, <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a> <i>reduceOptions</i> = UnorderedReduce | SequentialReduce )</h3> <p>Calls <i>mapFunction</i> once for each item from <i>begin</i> to <i>end</i>. The return value of each <i>mapFunction</i> is passed to <i>reduceFunction</i>.</p> <p>Note that while <i>mapFunction</i> is called concurrently, only one thread at a time will call <i>reduceFunction</i>. By default, the order in which <i>reduceFunction</i> is called is undefined.</p> <p><b>Note:</b> <a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::OrderedReduce</a> results in the ordered reduction.</p> <a name="//apple_ref/cpp/instm/QtConcurrent/run"></a> <h3 class="fn"><a name="run"></a><a href="qfuture.html">QFuture</a><T> QtConcurrent::run ( Function <i>function</i>, ... )</h3> <p>Runs <i>function</i> in a separate thread. The thread is taken from the global <a href="qthreadpool.html">QThreadPool</a>. Note that the function may not run immediately; the function will only be run when a thread is available.</p> <p>T is the same type as the return value of <i>function</i>. Non-void return values can be accessed via the <a href="qfuture.html#result">QFuture::result</a>() function.</p> <p>Note that the <a href="qfuture.html">QFuture</a> returned by QtConcurrent::run() does not support canceling, pausing, or progress reporting. The <a href="qfuture.html">QFuture</a> returned can only be used to query for the running/finished status and the return value of the function.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="40%" align="left">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td> <td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="40%" align="right"><div align="right">Qt 4.6.3</div></td> </tr></table></div></address></body> </html>