parallel_for_each 函式
parallel_for_each 會平行套用指定的函式到範圍內的每個項目。 在語意上相當於 std 命名空間中的 for_each 函式,但項目的反覆項目會平行執行,而且不會指定反覆項目的順序。 _Func 引數必須支援 operator()(T) 形式的函式呼叫運算子,其中 T 參數是要逐一查看的容器的項目型別。
template <
typename _Iterator,
typename _Function
>
void parallel_for_each(
_Iterator_First,
_Iterator_Last,
const _Function& _Func
);
template <
typename _Iterator,
typename _Function,
typename _Partitioner
>
void parallel_for_each(
_Iterator_First,
_Iterator_Last,
const _Function& _Func,
_Partitioner&& _Part
);
參數
_Iterator
用來反覆容器的 Iterator 的型別。_Function
將套用到範圍內每個項目之函式的型別。_Partitioner
_First
Iterator,定址要包含在平行反覆項目中第一個項目的位置。_Last
Iterator,定址要包含在平行反覆項目中通過最後一個項目的位置。_Func
套用於範圍中每個項目的使用者定義函式物件。_Part
分割器物件的參考。 引數可以是其中一個 constauto_partitioner&static_partitioner&, const,或 constsimple_partitioner& affinity_partitioner& ,如果使用 affinity_partitioner 物件,參考必須是非常數左值參考,因此,演算法可能儲存未來重複的狀態可以重複使用。
備註
auto_partitioner 為多載使用,而不用明確 Partitioner。
對於不支援隨機存取的 Iterator,只有 auto_partitioner 支援。
如需詳細資訊,請參閱平行演算法。
需求
標頭: ppl.h
**命名空間:**concurrency