<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qtconcurrentmap.cpp --> <title>QtConcurrent Namespace | Qt Concurrent 5.12.2</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtconcurrent-index.html">Qt Concurrent</a></td><td >QtConcurrent Namespace</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtconcurrent-index.html">Qt 5.12.2 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#classes">Classes</a></li> <li class="level1"><a href="#types">Types</a></li> <li class="level1"><a href="#functions">Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QtConcurrent Namespace</h1> <!-- $$$QtConcurrent-brief --> <p>The <a href="qtconcurrent-module.html">QtConcurrent</a> 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> <!-- @@@QtConcurrent --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QtConcurrent></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += concurrent</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 4.4</td></tr></table></div><ul> <li><a href="qtconcurrent-obsolete.html">Obsolete members</a></li> </ul> <a name="classes"></a> <h2 id="classes">Classes</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent-intermediateresults.html">IntermediateResults</a></b></td></tr> </table></div> <a name="types"></a> <h2 id="types">Types</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#ReduceOption-enum">ReduceOption</a></b> { UnorderedReduce, OrderedReduce, SequentialReduce }</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#ReduceOption-enum">ReduceOptions</a></b></td></tr> </table></div> <a name="functions"></a> <h2 id="functions">Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingFilter">blockingFilter</a></b>(Sequence &<i>sequence</i>, KeepFunctor <i>filterFunction</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Sequence </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingFiltered">blockingFiltered</a></b>(const Sequence &<i>sequence</i>, KeepFunctor <i>filterFunction</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> OutputSequence </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingFiltered-1">blockingFiltered</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, KeepFunctor <i>filterFunction</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> ResultType </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingFilteredReduced">blockingFilteredReduced</a></b>(const Sequence &<i>sequence</i>, KeepFunctor <i>filterFunction</i>, ReduceFunctor <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = ...)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> ResultType </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingFilteredReduced-1">blockingFilteredReduced</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, KeepFunctor <i>filterFunction</i>, ReduceFunctor <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = ...)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingMap">blockingMap</a></b>(Sequence &<i>sequence</i>, MapFunctor <i>function</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingMap-1">blockingMap</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, MapFunctor <i>function</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> OutputSequence </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingMapped">blockingMapped</a></b>(const InputSequence &<i>sequence</i>, MapFunctor <i>function</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Sequence </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingMapped-1">blockingMapped</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, MapFunctor <i>function</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> ResultType </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingMappedReduced">blockingMappedReduced</a></b>(const Sequence &<i>sequence</i>, MapFunctor <i>mapFunction</i>, ReduceFunctor <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = ...)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> ResultType </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#blockingMappedReduced-1">blockingMappedReduced</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, MapFunctor <i>mapFunction</i>, ReduceFunctor <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = ...)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<void> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#filter">filter</a></b>(Sequence &<i>sequence</i>, KeepFunctor <i>filterFunction</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<typename Sequence::value_type> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#filtered">filtered</a></b>(const Sequence &<i>sequence</i>, KeepFunctor <i>filterFunction</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<typename qValueType<Iterator>::value_type> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#filtered-1">filtered</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, KeepFunctor <i>filterFunction</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<ResultType> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#filteredReduced">filteredReduced</a></b>(const Sequence &<i>sequence</i>, KeepFunctor <i>filterFunction</i>, ReduceFunctor <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = ...)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<ResultType> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#filteredReduced-1">filteredReduced</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, KeepFunctor <i>filterFunction</i>, ReduceFunctor <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = ...)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<void> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#map">map</a></b>(Sequence &<i>sequence</i>, MapFunctor <i>function</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<void> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#map-1">map</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, MapFunctor <i>function</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#mapped">mapped</a></b>(const Sequence &<i>sequence</i>, MapFunctor <i>function</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#mapped-1">mapped</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, MapFunctor <i>function</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<ResultType> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#mappedReduced">mappedReduced</a></b>(const Sequence &<i>sequence</i>, MapFunctor <i>mapFunction</i>, ReduceFunctor <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = ...)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<ResultType> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#mappedReduced-1">mappedReduced</a></b>(Iterator <i>begin</i>, Iterator <i>end</i>, MapFunctor <i>mapFunction</i>, ReduceFunctor <i>reduceFunction</i>, QtConcurrent::ReduceOptions <i>reduceOptions</i> = ...)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<T> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#run">run</a></b>(Function <i>function</i>, <i>...</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFuture<T> </td><td class="memItemRight bottomAlign"><b><a href="qtconcurrent.html#run-1">run</a></b>(QThreadPool *<i>pool</i>, Function <i>function</i>, <i>...</i>)</td></tr> </table></div> <a name="details"></a> <!-- $$$QtConcurrent-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qtconcurrent-module.html">QtConcurrent</a> 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="qtconcurrent-index.html">Qt Concurrent</a> module documentation for an overview of available functions, or see below for detailed information on each function.</p> </div> <!-- @@@QtConcurrent --> <div class="classes"> <h2>Classes</h2> <h3> class <a href="qtconcurrent-intermediateresults.html">IntermediateResults</a></h3></div> <div class="types"> <h2>Type Documentation</h2> <!-- $$$ReduceOption$$$UnorderedReduce$$$OrderedReduce$$$SequentialReduce --> <h3 class="flags" id="ReduceOption-enum"><a name="ReduceOption-enum"></a>enum QtConcurrent::<span class="name">ReduceOption</span><br/>flags QtConcurrent::<span class="name">ReduceOptions</span></h3> <p>This enum specifies the order of which results from the map or filter function are passed to the reduce function.</p> <div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr> <tr><td class="topAlign"><code>QtConcurrent::UnorderedReduce</code></td><td class="topAlign tblval"><code>0x1</code></td><td class="topAlign">Reduction is done in an arbitrary order.</td></tr> <tr><td class="topAlign"><code>QtConcurrent::OrderedReduce</code></td><td class="topAlign tblval"><code>0x2</code></td><td class="topAlign">Reduction is done in the order of the original sequence.</td></tr> <tr><td class="topAlign"><code>QtConcurrent::SequentialReduce</code></td><td class="topAlign tblval"><code>0x4</code></td><td class="topAlign">Reduction is done sequentially: 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></div> <p>The ReduceOptions type is a typedef for <a href="../qtcore/qflags.html">QFlags</a><ReduceOption>. It stores an OR combination of ReduceOption values.</p> <!-- @@@ReduceOption --> </div> <div class="func"> <h2>Function Documentation</h2> <!-- $$$blockingFilter[overload1]$$$blockingFilterSequence&KeepFunctor --> <h3 class="fn" id="blockingFilter"><a name="blockingFilter"></a><span class="type">void</span> QtConcurrent::<span class="name">blockingFilter</span>(<span class="type">Sequence</span> &<i>sequence</i>, <span class="type">KeepFunctor</span> <i>filterFunction</i>)</h3> <p>Calls <i>filterFunction</i> once for each item in <i>sequence</i>. If <i>filterFunction</i> returns <code>true</code>, 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><p><b>See also </b><a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@blockingFilter --> <!-- $$$blockingFiltered[overload1]$$$blockingFilteredconstSequence&KeepFunctor --> <h3 class="fn" id="blockingFiltered"><a name="blockingFiltered"></a><span class="type">Sequence</span> QtConcurrent::<span class="name">blockingFiltered</span>(const <span class="type">Sequence</span> &<i>sequence</i>, <span class="type">KeepFunctor</span> <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 <code>true</code>, 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><b>See also </b><a href="qtconcurrent.html#filtered">filtered</a>() and <a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@blockingFiltered --> <!-- $$$blockingFiltered$$$blockingFilteredIteratorIteratorKeepFunctor --> <h3 class="fn" id="blockingFiltered-1"><a name="blockingFiltered-1"></a><span class="type">OutputSequence</span> QtConcurrent::<span class="name">blockingFiltered</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">KeepFunctor</span> <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 <code>true</code>, 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><b>See also </b><a href="qtconcurrent.html#filtered">filtered</a>() and <a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@blockingFiltered --> <!-- $$$blockingFilteredReduced[overload1]$$$blockingFilteredReducedconstSequence&KeepFunctorReduceFunctorQtConcurrent::ReduceOptions --> <h3 class="fn" id="blockingFilteredReduced"><a name="blockingFilteredReduced"></a><span class="type">ResultType</span> QtConcurrent::<span class="name">blockingFilteredReduced</span>(const <span class="type">Sequence</span> &<i>sequence</i>, <span class="type">KeepFunctor</span> <i>filterFunction</i>, <span class="type">ReduceFunctor</span> <i>reduceFunction</i>, <span class="type"><a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a></span> <i>reduceOptions</i> = ...)</h3> <p>Calls <i>filterFunction</i> once for each item in <i>sequence</i>. If <i>filterFunction</i> returns <code>true</code> 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 <code>true</code>.</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><b>See also </b><a href="qtconcurrent.html#filteredReduced">filteredReduced</a>() and <a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@blockingFilteredReduced --> <!-- $$$blockingFilteredReduced$$$blockingFilteredReducedIteratorIteratorKeepFunctorReduceFunctorQtConcurrent::ReduceOptions --> <h3 class="fn" id="blockingFilteredReduced-1"><a name="blockingFilteredReduced-1"></a><span class="type">ResultType</span> QtConcurrent::<span class="name">blockingFilteredReduced</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">KeepFunctor</span> <i>filterFunction</i>, <span class="type">ReduceFunctor</span> <i>reduceFunction</i>, <span class="type"><a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a></span> <i>reduceOptions</i> = ...)</h3> <p>Calls <i>filterFunction</i> once for each item from <i>begin</i> to <i>end</i>. If <i>filterFunction</i> returns <code>true</code> 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 <code>true</code>.</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><b>See also </b><a href="qtconcurrent.html#filteredReduced">filteredReduced</a>() and <a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@blockingFilteredReduced --> <!-- $$$blockingMap[overload1]$$$blockingMapSequence&MapFunctor --> <h3 class="fn" id="blockingMap"><a name="blockingMap"></a><span class="type">void</span> QtConcurrent::<span class="name">blockingMap</span>(<span class="type">Sequence</span> &<i>sequence</i>, <span class="type">MapFunctor</span> <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><b>See also </b><a href="qtconcurrent.html#map">map</a>() and <a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@blockingMap --> <!-- $$$blockingMap$$$blockingMapIteratorIteratorMapFunctor --> <h3 class="fn" id="blockingMap-1"><a name="blockingMap-1"></a><span class="type">void</span> QtConcurrent::<span class="name">blockingMap</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">MapFunctor</span> <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><b>See also </b><a href="qtconcurrent.html#map">map</a>() and <a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@blockingMap --> <!-- $$$blockingMapped[overload1]$$$blockingMappedconstInputSequence&MapFunctor --> <h3 class="fn" id="blockingMapped"><a name="blockingMapped"></a><span class="type">OutputSequence</span> QtConcurrent::<span class="name">blockingMapped</span>(const <span class="type">InputSequence</span> &<i>sequence</i>, <span class="type">MapFunctor</span> <i>function</i>)</h3> <p>Calls <i>function</i> once for each item in <i>sequence</i> and returns an OutputSequence containing the results. The type of the results will match the type returned my the MapFunctor.</p> <p><b>Note: </b>This function will block until all items in the sequence have been processed.</p><p><b>See also </b><a href="qtconcurrent.html#mapped">mapped</a>() and <a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@blockingMapped --> <!-- $$$blockingMapped$$$blockingMappedIteratorIteratorMapFunctor --> <h3 class="fn" id="blockingMapped-1"><a name="blockingMapped-1"></a><span class="type">Sequence</span> QtConcurrent::<span class="name">blockingMapped</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">MapFunctor</span> <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 class="cpp"> <span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator"><</span><span class="type">int</span><span class="operator">></span> ints <span class="operator">=</span> <span class="type">QtConcurrent</span><span class="operator">::</span>blockingMapped<span class="operator"><</span><span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator"><</span><span class="type">int</span><span class="operator">></span> <span class="operator">></span>(beginIterator<span class="operator">,</span> endIterator<span class="operator">,</span> fn); </pre> <p><b>Note: </b>This function will block until the iterator reaches the end of the sequence being processed.</p><p><b>See also </b><a href="qtconcurrent.html#mapped">mapped</a>() and <a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@blockingMapped --> <!-- $$$blockingMappedReduced[overload1]$$$blockingMappedReducedconstSequence&MapFunctorReduceFunctorQtConcurrent::ReduceOptions --> <h3 class="fn" id="blockingMappedReduced"><a name="blockingMappedReduced"></a><span class="type">ResultType</span> QtConcurrent::<span class="name">blockingMappedReduced</span>(const <span class="type">Sequence</span> &<i>sequence</i>, <span class="type">MapFunctor</span> <i>mapFunction</i>, <span class="type">ReduceFunctor</span> <i>reduceFunction</i>, <span class="type"><a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a></span> <i>reduceOptions</i> = ...)</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><b>See also </b><a href="qtconcurrent.html#mapped">mapped</a>() and <a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@blockingMappedReduced --> <!-- $$$blockingMappedReduced$$$blockingMappedReducedIteratorIteratorMapFunctorReduceFunctorQtConcurrent::ReduceOptions --> <h3 class="fn" id="blockingMappedReduced-1"><a name="blockingMappedReduced-1"></a><span class="type">ResultType</span> QtConcurrent::<span class="name">blockingMappedReduced</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">MapFunctor</span> <i>mapFunction</i>, <span class="type">ReduceFunctor</span> <i>reduceFunction</i>, <span class="type"><a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a></span> <i>reduceOptions</i> = ...)</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><b>See also </b><a href="qtconcurrent.html#blockingMappedReduced">blockingMappedReduced</a>() and <a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@blockingMappedReduced --> <!-- $$$filter[overload1]$$$filterSequence&KeepFunctor --> <h3 class="fn" id="filter"><a name="filter"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">void</span>> QtConcurrent::<span class="name">filter</span>(<span class="type">Sequence</span> &<i>sequence</i>, <span class="type">KeepFunctor</span> <i>filterFunction</i>)</h3> <p>Calls <i>filterFunction</i> once for each item in <i>sequence</i>. If <i>filterFunction</i> returns <code>true</code>, the item is kept in <i>sequence</i>; otherwise, the item is removed from <i>sequence</i>.</p> <p><b>See also </b><a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@filter --> <!-- $$$filtered[overload1]$$$filteredconstSequence&KeepFunctor --> <h3 class="fn" id="filtered"><a name="filtered"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">typename</span> <span class="type">Sequence::value_type</span>> QtConcurrent::<span class="name">filtered</span>(const <span class="type">Sequence</span> &<i>sequence</i>, <span class="type">KeepFunctor</span> <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 <code>true</code>, 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>See also </b><a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@filtered --> <!-- $$$filtered$$$filteredIteratorIteratorKeepFunctor --> <h3 class="fn" id="filtered-1"><a name="filtered-1"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">typename</span> <span class="type">qValueType</span><<span class="type">Iterator</span>><span class="type">::value_type</span>> QtConcurrent::<span class="name">filtered</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">KeepFunctor</span> <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 <code>true</code>, 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>See also </b><a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@filtered --> <!-- $$$filteredReduced[overload1]$$$filteredReducedconstSequence&KeepFunctorReduceFunctorQtConcurrent::ReduceOptions --> <h3 class="fn" id="filteredReduced"><a name="filteredReduced"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">ResultType</span>> QtConcurrent::<span class="name">filteredReduced</span>(const <span class="type">Sequence</span> &<i>sequence</i>, <span class="type">KeepFunctor</span> <i>filterFunction</i>, <span class="type">ReduceFunctor</span> <i>reduceFunction</i>, <span class="type"><a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a></span> <i>reduceOptions</i> = ...)</h3> <p>Calls <i>filterFunction</i> once for each item in <i>sequence</i>. If <i>filterFunction</i> returns <code>true</code> 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 <code>true</code>.</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>See also </b><a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@filteredReduced --> <!-- $$$filteredReduced$$$filteredReducedIteratorIteratorKeepFunctorReduceFunctorQtConcurrent::ReduceOptions --> <h3 class="fn" id="filteredReduced-1"><a name="filteredReduced-1"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">ResultType</span>> QtConcurrent::<span class="name">filteredReduced</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">KeepFunctor</span> <i>filterFunction</i>, <span class="type">ReduceFunctor</span> <i>reduceFunction</i>, <span class="type"><a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a></span> <i>reduceOptions</i> = ...)</h3> <p>Calls <i>filterFunction</i> once for each item from <i>begin</i> to <i>end</i>. If <i>filterFunction</i> returns <code>true</code> 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 <code>true</code>.</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>See also </b><a href="qtconcurrentfilter.html">Concurrent Filter and Filter-Reduce</a>.</p> <!-- @@@filteredReduced --> <!-- $$$map[overload1]$$$mapSequence&MapFunctor --> <h3 class="fn" id="map"><a name="map"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">void</span>> QtConcurrent::<span class="name">map</span>(<span class="type">Sequence</span> &<i>sequence</i>, <span class="type">MapFunctor</span> <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>See also </b><a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@map --> <!-- $$$map$$$mapIteratorIteratorMapFunctor --> <h3 class="fn" id="map-1"><a name="map-1"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">void</span>> QtConcurrent::<span class="name">map</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">MapFunctor</span> <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>See also </b><a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@map --> <!-- $$$mapped[overload1]$$$mappedconstSequence&MapFunctor --> <h3 class="fn" id="mapped"><a name="mapped"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">typename</span> <span class="type"><a href="qtprivate-mapresulttype.html">QtPrivate::MapResultType</a></span><<span class="type">void</span>, <span class="type">MapFunctor</span>><span class="type">::ResultType</span>> QtConcurrent::<span class="name">mapped</span>(const <span class="type">Sequence</span> &<i>sequence</i>, <span class="type">MapFunctor</span> <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="../qtcore/qfuture-const-iterator.html">QFuture::const_iterator</a> or <a href="../qtcore/qfutureiterator.html">QFutureIterator</a> to iterate through the results.</p> <p><b>See also </b><a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@mapped --> <!-- $$$mapped$$$mappedIteratorIteratorMapFunctor --> <h3 class="fn" id="mapped-1"><a name="mapped-1"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">typename</span> <span class="type"><a href="qtprivate-mapresulttype.html">QtPrivate::MapResultType</a></span><<span class="type">void</span>, <span class="type">MapFunctor</span>><span class="type">::ResultType</span>> QtConcurrent::<span class="name">mapped</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">MapFunctor</span> <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="../qtcore/qfuture-const-iterator.html">QFuture::const_iterator</a> or <a href="../qtcore/qfutureiterator.html">QFutureIterator</a> to iterate through the results.</p> <p><b>See also </b><a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@mapped --> <!-- $$$mappedReduced[overload1]$$$mappedReducedconstSequence&MapFunctorReduceFunctorQtConcurrent::ReduceOptions --> <h3 class="fn" id="mappedReduced"><a name="mappedReduced"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">ResultType</span>> QtConcurrent::<span class="name">mappedReduced</span>(const <span class="type">Sequence</span> &<i>sequence</i>, <span class="type">MapFunctor</span> <i>mapFunction</i>, <span class="type">ReduceFunctor</span> <i>reduceFunction</i>, <span class="type"><a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a></span> <i>reduceOptions</i> = ...)</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>See also </b><a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@mappedReduced --> <!-- $$$mappedReduced$$$mappedReducedIteratorIteratorMapFunctorReduceFunctorQtConcurrent::ReduceOptions --> <h3 class="fn" id="mappedReduced-1"><a name="mappedReduced-1"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">ResultType</span>> QtConcurrent::<span class="name">mappedReduced</span>(<span class="type">Iterator</span> <i>begin</i>, <span class="type">Iterator</span> <i>end</i>, <span class="type">MapFunctor</span> <i>mapFunction</i>, <span class="type">ReduceFunctor</span> <i>reduceFunction</i>, <span class="type"><a href="qtconcurrent.html#ReduceOption-enum">QtConcurrent::ReduceOptions</a></span> <i>reduceOptions</i> = ...)</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><p><b>See also </b><a href="qtconcurrentmap.html">Concurrent Map and Map-Reduce</a>.</p> <!-- @@@mappedReduced --> <!-- $$$run[overload1]$$$runFunction... --> <h3 class="fn" id="run"><a name="run"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">T</span>> QtConcurrent::<span class="name">run</span>(<span class="type">Function</span> <i>function</i>, <i>...</i>)</h3> <p>Equivalent to</p> <pre class="cpp"> <span class="type">QtConcurrent</span><span class="operator">::</span>run(<span class="type"><a href="../qtcore/qthreadpool.html">QThreadPool</a></span><span class="operator">::</span>globalInstance()<span class="operator">,</span> function<span class="operator">,</span> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>); </pre> <p>Runs <i>function</i> in a separate thread. The thread is taken from the global <a href="../qtcore/qthreadpool.html">QThreadPool</a>. Note that <i>function</i> may not run immediately; <i>function</i> will only be run once a thread becomes 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="../qtcore/qfuture.html#result">QFuture::result</a>() function.</p> <p>Note that the <a href="../qtcore/qfuture.html">QFuture</a> returned by QtConcurrent::run() does not support canceling, pausing, or progress reporting. The <a href="../qtcore/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><b>See also </b><a href="qtconcurrentrun.html">Concurrent Run</a>.</p> <!-- @@@run --> <!-- $$$run$$$runQThreadPool*Function... --> <h3 class="fn" id="run-1"><a name="run-1"></a><span class="type"><a href="../qtcore/qfuture.html">QFuture</a></span><<span class="type">T</span>> QtConcurrent::<span class="name">run</span>(<span class="type"><a href="../qtcore/qthreadpool.html">QThreadPool</a></span> *<i>pool</i>, <span class="type">Function</span> <i>function</i>, <i>...</i>)</h3> <p>Runs <i>function</i> in a separate thread. The thread is taken from the <a href="../qtcore/qthreadpool.html">QThreadPool</a> <i>pool</i>. Note that <i>function</i> may not run immediately; <i>function</i> will only be run once a thread becomes 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="../qtcore/qfuture.html#result">QFuture::result</a>() function.</p> <p>Note that the <a href="../qtcore/qfuture.html">QFuture</a> returned by QtConcurrent::run() does not support canceling, pausing, or progress reporting. The <a href="../qtcore/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>This function was introduced in Qt 5.4.</p> <p><b>See also </b><a href="qtconcurrentrun.html">Concurrent Run</a>.</p> <!-- @@@run --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>