共用方式為


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
    Partitioner 物件參考。 引數可為任一constauto_partitioner&conststatic_partitioner&constsimple_partitioner**&affinity_partitioner&**如果 affinity_partitioner 物件,則參照來源必須非常值 (l-value) 的參考,如此演算法可以儲存的未來的迴圈,以重複使用的狀態。

備註

auto_partitioner 做為多載,而不需明確的 partitioner。

Iterator 不支援隨機存取,請只對 auto_partitioner 支援。

如需詳細資訊,請參閱 平行演算法

需求

標頭: ppl.h

Namespace: 並行存取

請參閱

參考

concurrency 命名空間