Most data are screening a list using a for loop to achieve, perhaps using QtConcurrent :: blockingFilter will be more concise.
Be used: a list of integer sequence, screening requires the data is greater than 5.
QList<int> sequence{1, 10, 3, 5, 6, 9, 7, 2, 4};
Screening using a for loop
QList<int> list;
for (int i = 0; i < sequence.count(); i++) {
if (sequence.at(i) > 5) {
list.append(sequence.at(i));
}
}
sequence = list;
Screening using blockingFilter Interface
blockingFilter is QtConcurrent namespace interface, the main role is to screen out qualified value of the result set entries, and with the replacement of the original sequence list . There associated map (map), reduce (induction).
QtConcurrent::blockingFilter(sequence, [](int v) { return v > 5; });