Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qtconcurrentmap

\title Concurrent Map and Map-Reduce

Transforming values from a sequence and combining them, all in parallel.

The QtConcurrent::map(), QtConcurrent::mapped() and QtConcurrent::mappedReduced() functions run computations in parallel on the items in a sequence such as a QList. QtConcurrent::map() modifies a sequence in-place, QtConcurrent::mapped() returns a new sequence containing the modified content, and QtConcurrent::mappedReduced() returns a single result.

These functions are part of the \l {Qt Concurrent} framework.

Each of the above functions has a blocking variant that returns the final result instead of a QFuture. You use them in the same way as the asynchronous variants.

// Each call blocks until the entire operation is finished.
\inmodule QtGui
Definition qimage.h:37
Definition qlist.h:74
void blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor map)
Calls function once for each item in sequence.
ResultType blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&map, ReduceFunctor &&reduce, ReduceOptions options=ReduceOptions(UnorderedReduce|SequentialReduce))
OutputSequence blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&map)
Calls function once for each item in sequence and returns an OutputSequence containing the results.
GLenum GLenum GLenum GLenum GLenum scale
QList< QImage > images
[6]
QFuture< QImage > collage
[15]
void addToCollage(QImage &collage, const QImage &grayscaleImage)
QFuture< void > future
[5]
QImage scaled(const QImage &image)
[0]

Note that the result types above are not QFuture objects, but real result types (in this case, QList<QImage> and QImage).