命名空间
变体
操作

现有算法的并行化版本 (parallelism TS)

来自 cppreference.com

C++ 并行扩展 TS 提供了以下 69 个现有算法的并行化版本。以下每个并行化算法

  • std::experimental::parallel 命名空间中声明,
  • 除非 is_execution_policy<std::decay_t<ExecutionPolicy>>::valuetrue,否则不参与重载解析,并且
  • 与 C++ 标准库中相应的现有算法具有相同的语义,除非在关于 并行算法 的页面中注明。


内容

非修改序列操作
并行化算法 现有算法
template< class ExecutionPolicy, class InputIt, class UnaryPred >

bool all_of( ExecutionPolicy&& policy, InputIt first, InputIt last,
             UnaryPred p );

std::all_of
template< class ExecutionPolicy, class InputIt, class UnaryPred >

bool any_of( ExecutionPolicy&& policy, InputIt first, InputIt last,
             UnaryPred p );

std::any_of
template< class ExecutionPolicy, class InputIt, class UnaryPred >

bool none_of( ExecutionPolicy&& policy, InputIt first, InputIt last,
              UnaryPred p );

std::none_of
template< class ExecutionPolicy, class InputIt, class T >

typename iterator_traits<InputIt>::difference_type
    count( ExecutionPolicy&& policy, InputIt first, InputIt last,
           const T &value );

std::count
template< class ExecutionPolicy, class InputIt, class UnaryPred >

typename iterator_traits<InputIt>::difference_type
    count_if( ExecutionPolicy&& policy, InputIt first, InputIt last,
              UnaryPred p );

std::count_if
template< class ExecutionPolicy, class InputIt1, class InputIt2 >

std::pair<InputIt1,InputIt2>
    mismatch( ExecutionPolicy&& policy,
              InputIt1 first1, InputIt1 last1,
              InputIt2 first2 );

template< class ExecutionPolicy, class InputIt1,
          class InputIt2, class BinaryPred >
std::pair<InputIt1,InputIt2>
    mismatch( ExecutionPolicy&& policy,
              InputIt1 first1, InputIt1 last1,
              InputIt2 first2, BinaryPred p );

template< class ExecutionPolicy, class InputIt1, class InputIt2 >
std::pair<InputIt1,InputIt2>
    mismatch( ExecutionPolicy&& policy,
              InputIt1 first1, InputIt1 last1,
              InputIt2 first2, InputIt2 last2 );

template< class ExecutionPolicy, class InputIt1,
          class InputIt2, class BinaryPred >
std::pair<InputIt1,InputIt2>
    mismatch( ExecutionPolicy&& policy,
              InputIt1 first1, InputIt1 last1,
              InputIt2 first2, InputIt2 last2, BinaryPred p );

std::mismatch
template< class ExecutionPolicy, class InputIt1, class InputIt2 >

bool equal( ExecutionPolicy&& policy,
            InputIt1 first1, InputIt1 last1,
            InputIt2 first2 );

template< class ExecutionPolicy, class InputIt1,
          class InputIt2, class BinaryPred >
bool equal( ExecutionPolicy&& policy,
            InputIt1 first1, InputIt1 last1,
            InputIt2 first2, BinaryPred p );

template< class ExecutionPolicy, class InputIt1, class InputIt2 >
bool equal( ExecutionPolicy&& policy,
            InputIt1 first1, InputIt1 last1,
            InputIt2 first2, InputIt2 last2 );

template< class ExecutionPolicy, class InputIt1,
          class InputIt2, class BinaryPred >
bool equal( ExecutionPolicy&& policy,
            InputIt1 first1, InputIt1 last1,
            InputIt2 first2, InputIt2 last2, BinaryPred p );

std::equal
template< class ExecutionPolicy, class InputIt, class T >

InputIt find( ExecutionPolicy&& policy, InputIt first, InputIt last,
              const T& value );

std::find
template< class ExecutionPolicy, class InputIt, class UnaryPred >

InputIt find_if( ExecutionPolicy&& policy, InputIt first, InputIt last,
                 UnaryPred p );

std::find_if
template< class ExecutionPolicy, class InputIt, class UnaryPred >

InputIt find_if_not( ExecutionPolicy&& policy,
                     InputIt first, InputIt last,
                     UnaryPred p );

std::find_if_not
template< class ExecutionPolicy, class ForwardIt1, class ForwardIt2 >

ForwardIt1 find_end( ExecutionPolicy&& policy,
                     ForwardIt1 first, ForwardIt1 last,
                     ForwardIt2 s_first, ForwardIt2 s_last );
       
template< class ExecutionPolicy, class ForwardIt1,
          class ForwardIt2, class BinaryPred >
ForwardIt1 find_end( ExecutionPolicy&& policy,
                     ForwardIt1 first, ForwardIt1 last,
                     ForwardIt2 s_first, ForwardIt2 s_last,
                     BinaryPred p );

std::find_end
template< class ExecutionPolicy, class InputIt, class ForwardIt >

InputIt find_first_of( ExecutionPolicy&& policy,
                       InputIt first, InputIt last,
                       ForwardIt s_first, ForwardIt s_last );

template< class ExecutionPolicy, class InputIt,
          class ForwardIt, class BinaryPred >
InputIt find_first_of( ExecutionPolicy&& policy,
                       InputIt first, InputIt last,
                       ForwardIt s_first, ForwardIt s_last,
                       BinaryPred p );

std::find_first_of
template< class ExecutionPolicy, class ForwardIt >

ForwardIt adjacent_find( ExecutionPolicy&& policy,
                         ForwardIt first, ForwardIt last );
       
template< class ExecutionPolicy, class ForwardIt, class BinaryPred >
ForwardIt adjacent_find( ExecutionPolicy&& policy,
                         ForwardIt first, ForwardIt last,
                         BinaryPred p );

std::adjacent_find
template< class ExecutionPolicy, class ForwardIt1, class ForwardIt2 >

ForwardIt1 search( ExecutionPolicy&& policy,
                   ForwardIt1 first, ForwardIt1 last,
                   ForwardIt2 s_first, ForwardIt2 s_last );

template< class ExecutionPolicy, class ForwardIt1,
          class ForwardIt2, class BinaryPred >
ForwardIt1 search( ExecutionPolicy&& policy,
                   ForwardIt1 first, ForwardIt1 last,
                   ForwardIt2 s_first, ForwardIt2 s_last,
                   BinaryPred p );

std::search
template< class ExecutionPolicy, class ForwardIt, class Size, class T >

ForwardIt search_n( ExecutionPolicy&& policy,
                    ForwardIt first, ForwardIt last,
                    Size count, const T& value );
       
template< class ExecutionPolicy, class ForwardIt,
          class Size, class T, class BinaryPred >
ForwardIt search_n( ExecutionPolicy&& policy,
                    ForwardIt first, ForwardIt last,
                    Size count, const T& value,
                    BinaryPred p );

std::search_n
修改序列操作
并行化算法 现有算法
template< class ExecutionPolicy, class InputIt, class OutputIt >

OutputIt copy( ExecutionPolicy&& policy, InputIt first, InputIt last,
               OutputIt d_first );

std::copy
template< class ExecutionPolicy, class InputIt,

          class OutputIt, class UnaryPred >
OutputIt copy_if( ExecutionPolicy&& policy, InputIt first, InputIt last,
                  OutputIt d_first, UnaryPred pred );

std::copy_if
template< class ExecutionPolicy, class InputIt,

          class Size, class OutputIt >
OutputIt copy_n( ExecutionPolicy&& policy, InputIt first, Size count,
                 OutputIt result );

std::copy_n
template< class ExecutionPolicy, class InputIt, class OutputIt >

OutputIt move( ExecutionPolicy&& policy, InputIt first, InputIt last,
               OutputIt d_first );

std::move
template< class ExecutionPolicy, class ForwardIt, class T >

void fill( ExecutionPolicy&& policy, ForwardIt first, ForwardIt last,
           const T& value );

std::fill
template< class ExecutionPolicy, class OutputIt, class Size, class T >

OutputIt fill_n( ExecutionPolicy&& policy, OutputIt first, Size count,
                 const T& value );

std::fill_n
模板< ExecutionPolicy, InputIt,

          OutputIt, UnaryOp >
OutputIt transform( ExecutionPolicy&& policy,
                    InputIt first1, InputIt last1,
                    OutputIt d_first, UnaryOp unary_op );

模板< ExecutionPolicy, InputIt1, InputIt2,
          OutputIt, BinaryOp >
OutputIt transform( ExecutionPolicy&& policy,
                    InputIt1 first1, InputIt1 last1,
                    InputIt2 first2, OutputIt d_first,
                    BinaryOp binary_op );

std::transform
模板< ExecutionPolicy, ForwardIt, Generator >

void generate( ExecutionPolicy&& policy, ForwardIt first, ForwardIt last,
               Generator g );

std::generate
模板< ExecutionPolicy, OutputIt,

          Size, Generator >
OutputIt generate_n( ExecutionPolicy&& policy, OutputIt first,
                     Size count, Generator g );

std::generate_n
模板< ExecutionPolicy, ForwardIt, T >

ForwardIt remove( ExecutionPolicy&& policy,
                  ForwardIt first, ForwardIt last, const T& value );

std::remove
模板< ExecutionPolicy, ForwardIt, UnaryPred >

ForwardIt remove_if( ExecutionPolicy&& policy,
                     ForwardIt first, ForwardIt last, UnaryPred p );

std::remove_if
模板< ExecutionPolicy, InputIt, OutputIt, T >

OutputIt remove_copy( ExecutionPolicy&& policy,
                      InputIt first, InputIt last,
                      OutputIt d_first, const T& value );

std::remove_copy
模板< ExecutionPolicy, InputIt,

          OutputIt, UnaryPred >
OutputIt remove_copy_if( ExecutionPolicy&& policy,
                         InputIt first, InputIt last,
                         OutputIt d_first, UnaryPred p );

std::remove_copy_if
模板< ExecutionPolicy, ForwardIt, T >

void replace( ExecutionPolicy&& policy,
              ForwardIt first, ForwardIt last,
              const T& old_value, const T& new_value );

std::replace
模板< ExecutionPolicy, ForwardIt,

          UnaryPred, T >
void replace_if( ExecutionPolicy&& policy,
                 ForwardIt first, ForwardIt last,
                 UnaryPred p, const T& new_value );

std::replace_if
模板< ExecutionPolicy, InputIt, OutputIt, T >

OutputIt replace_copy( ExecutionPolicy&& policy,
                       InputIt first, InputIt last, OutputIt d_first,
                       const T& old_value, const T& new_value );

std::replace_copy
模板< ExecutionPolicy, InputIt, OutputIt,

          UnaryPred, T >
OutputIt replace_copy_if( ExecutionPolicy&& policy,
                          InputIt first, InputIt last, OutputIt d_first,
                          UnaryPred p, const T& new_value );

std::replace_copy_if
模板< ExecutionPolicy, ForwardIt1, ForwardIt2 >

ForwardIt2 swap_ranges( ExecutionPolicy&& policy,
                        ForwardIt1 first1, ForwardIt1 last1,
                        ForwardIt2 first2 );

std::swap_ranges
模板< ExecutionPolicy, BidirIt >

void reverse( ExecutionPolicy&& policy, BidirIt first, BidirIt last );

std::reverse
模板< ExecutionPolicy, BidirIt, OutputIt >

OutputIt reverse_copy( ExecutionPolicy&& policy,
                       BidirIt first, BidirIt last, OutputIt d_first );

std::reverse_copy
模板< ExecutionPolicy, ForwardIt >

ForwardIt rotate( ExecutionPolicy&& policy,
                  ForwardIt first, ForwardIt n_first, ForwardIt last );

std::rotate
模板< ExecutionPolicy, ForwardIt, OutputIt >

OutputIt rotate_copy( ExecutionPolicy&& policy,
                      ForwardIt first, ForwardIt n_first, ForwardIt last,
                      OutputIt d_first );

std::rotate_copy
模板< ExecutionPolicy, ForwardIt >

ForwardIt unique( ExecutionPolicy&& policy,
                  ForwardIt first, ForwardIt last );

模板< ExecutionPolicy, ForwardIt, BinaryPred >
ForwardIt unique( ExecutionPolicy&& policy,
                  ForwardIt first, ForwardIt last, BinaryPred p );

std::unique
模板< ExecutionPolicy, InputIt, OutputIt >

OutputIt unique_copy( ExecutionPolicy&& policy,
                      InputIt first, InputIt last,
                      OutputIt d_first );

模板< ExecutionPolicy, InputIt,
          OutputIt, BinaryPred >
OutputIt unique_copy( ExecutionPolicy&& policy,
                      InputIt first, InputIt last,
                      OutputIt d_first, BinaryPred p );

std::unique_copy
分区操作
并行化算法 现有算法
模板< ExecutionPolicy, InputIt, UnaryPred >

bool is_partitioned( ExecutionPolicy&& policy,
                     InputIt first, InputIt last, UnaryPred p );

std::is_partitioned
template< class ExecutionPolicy, class ForwardIt, class UnaryPred >

ForwardIt partition( ExecutionPolicy&& policy,
                     ForwardIt first, ForwardIt last, UnaryPred p );

std::partition
template< class ExecutionPolicy, class InputIt, class OutputIt1,

          class OutputIt2, class UnaryPred >
std::pair<OutputIt1, OutputIt2>
     partition_copy( ExecutionPolicy&& policy,
                     InputIt first, InputIt last,
                     OutputIt1 d_first_true, OutputIt2 d_first_false,
                     UnaryPred p );

std::partition_copy
template< class ExecutionPolicy, class BidirIt, class UnaryPred >

BidirIt stable_partition( ExecutionPolicy&& policy,
                          BidirIt first, BidirIt last, UnaryPred p );

std::stable_partition
排序操作
并行化算法 现有算法
template< class ExecutionPolicy, class ForwardIt >

bool is_sorted( ExecutionPolicy&& policy,
                ForwardIt first, ForwardIt last );

template< class ExecutionPolicy, class ForwardIt, class Compare >
bool is_sorted( ExecutionPolicy&& policy,
                ForwardIt first, ForwardIt last, Compare cmp );

std::is_sorted
template< class ExecutionPolicy, class ForwardIt >

ForwardIt is_sorted_until( ExecutionPolicy&& policy,
                           ForwardIt first, ForwardIt last );

template< class ExecutionPolicy, class ForwardIt, class Compare >
ForwardIt is_sorted_until( ExecutionPolicy&& policy,
                           ForwardIt first, ForwardIt last,
                           Compare cmp );

std::is_sorted_until
template< class ExecutionPolicy, class RandomIt >

void sort( ExecutionPolicy&& policy, RandomIt first, RandomIt last );

template< class ExecutionPolicy, class RandomIt, class Compare >
void sort( ExecutionPolicy&& policy,
           RandomIt first, RandomIt last, Compare cmp );

std::sort
template< class ExecutionPolicy, class RandomIt >

void partial_sort( ExecutionPolicy&& policy,
                   RandomIt first, RandomIt middle, RandomIt last );

template< class ExecutionPolicy, class RandomIt, class Compare >
void partial_sort( ExecutionPolicy&& policy,
                   RandomIt first, RandomIt middle, RandomIt last,
                   Compare cmp );

std::partial_sort
template< class ExecutionPolicy, class InputIt, class RandomIt >

RandomIt partial_sort_copy( ExecutionPolicy&& policy,
                            InputIt first, InputIt last,
                            RandomIt d_first, RandomIt d_last );

template< class ExecutionPolicy, class InputIt,
          class RandomIt, class Compare >
RandomIt partial_sort_copy( ExecutionPolicy&& policy,
                            InputIt first, InputIt last,
                            RandomIt d_first, RandomIt d_last,
                            Compare cmp );

std::partial_sort_copy
template< class ExecutionPolicy, class RandomIt >

void stable_sort( ExecutionPolicy&& policy,
                  RandomIt first, RandomIt last );

template< class ExecutionPolicy, class RandomIt, class Compare >
void stable_sort( ExecutionPolicy&& policy,
                  RandomIt first, RandomIt last, Compare cmp );

std::stable_sort
template< class ExecutionPolicy, class RandomIt >

void nth_element( ExecutionPolicy&& policy,
                  RandomIt first, RandomIt nth, RandomIt last );

template< class ExecutionPolicy, class RandomIt, class Compare >
void nth_element( ExecutionPolicy&& policy,
                  RandomIt first, RandomIt nth, RandomIt last,
                  Compare cmp );

std::nth_element
集合操作(在排序范围内)
并行化算法 现有算法
template< class ExecutionPolicy, class InputIt1,

          class InputIt2, class OutputIt >
OutputIt merge( ExecutionPolicy&& policy,
                InputIt1 first1, InputIt1 last1,
                InputIt2 first2, InputIt2 last2,
                OutputIt d_first );

template< class ExecutionPolicy, class InputIt1, class InputIt2,
          class OutputIt, class Compare >
OutputIt merge( ExecutionPolicy&& policy,
                InputIt1 first1, InputIt1 last1,
                InputIt2 first2, InputIt2 last2,
                OutputIt d_first, Compare cmp );

std::merge
template< class ExecutionPolicy, class BidirIt >

void inplace_merge( ExecutionPolicy&& policy,
                    BidirIt first, BidirIt middle, BidirIt last );

template< class ExecutionPolicy, class BidirIt, class Compare >
void inplace_merge( ExecutionPolicy&& policy,
                    BidirIt first, BidirIt middle, BidirIt last,
                    Compare cmp );

std::inplace_merge
template< class ExecutionPolicy, class InputIt1, class InputIt2 >

bool includes( ExecutionPolicy&& policy,
               InputIt1 first1, InputIt1 last1,
               InputIt2 first2, InputIt2 last2 );

template< class ExecutionPolicy, class InputIt1,
          class InputIt2, class Compare >
bool includes( ExecutionPolicy&& policy,
               InputIt1 first1, InputIt1 last1,
               InputIt2 first2, InputIt2 last2, Compare cmp );

std::includes
模板< ExecutionPolicy, InputIt1,

          InputIt2, OutputIt >
OutputIt set_difference( ExecutionPolicy&& policy,
                         InputIt1 first1, InputIt1 last1,
                         InputIt2 first2, InputIt2 last2,
                         OutputIt d_first );

模板< ExecutionPolicy, InputIt1, InputIt2,
          OutputIt, Compare >
OutputIt set_difference( ExecutionPolicy&& policy,
                         InputIt1 first1, InputIt1 last1,
                         InputIt2 first2, InputIt2 last2,
                         OutputIt d_first, Compare cmp );

std::set_difference
模板< ExecutionPolicy, InputIt1,

          InputIt2, OutputIt >
OutputIt set_intersection( ExecutionPolicy&& policy,
                           InputIt1 first1, InputIt1 last1,
                           InputIt2 first2, InputIt2 last2,
                           OutputIt d_first );

模板< ExecutionPolicy, InputIt1, InputIt2,
          OutputIt, Compare >
OutputIt set_intersection( ExecutionPolicy&& policy,
                           InputIt1 first1, InputIt1 last1,
                           InputIt2 first2, InputIt2 last2,
                           OutputIt d_first, Compare cmp );

std::set_intersection
模板< ExecutionPolicy, InputIt1,

          InputIt2, OutputIt >
OutputIt set_symmetric_difference( ExecutionPolicy&& policy,
                                   InputIt1 first1, InputIt1 last1,
                                   InputIt2 first2, InputIt2 last2,
                                   OutputIt d_first );

模板< ExecutionPolicy, InputIt1, InputIt2,
          OutputIt, Compare >
OutputIt set_symmetric_difference( ExecutionPolicy&& policy,
                                   InputIt1 first1, InputIt1 last1,
                                   InputIt2 first2, InputIt2 last2,
                                   OutputIt d_first, Compare cmp );

std::set_symmetric_difference
模板< ExecutionPolicy, InputIt1,

          InputIt2, OutputIt >
OutputIt set_union( ExecutionPolicy&& policy,
                    InputIt1 first1, InputIt1 last1,
                    InputIt2 first2, InputIt2 last2,
                    OutputIt d_first );

模板< ExecutionPolicy, InputIt1, InputIt2,
          OutputIt, Compare >
OutputIt set_union( ExecutionPolicy&& policy,
                    InputIt1 first1, InputIt1 last1,
                    InputIt2 first2, InputIt2 last2,
                    OutputIt d_first, Compare cmp );

std::set_union
堆操作
并行化算法 现有算法
模板< ExecutionPolicy, RandomIt >

布尔 is_heap( ExecutionPolicy&& policy,
              RandomIt first, RandomIt last );

模板< ExecutionPolicy, RandomIt, Compare >
布尔 is_heap( ExecutionPolicy&& policy,
              RandomIt first, RandomIt last, Compare cmp );

std::is_heap
模板< ExecutionPolicy, RandomIt >

RandomIt is_heap_until( ExecutionPolicy&& policy,
                        RandomIt first, RandomIt last );

模板< ExecutionPolicy, RandomIt, Compare >
RandomIt is_heap_until( ExecutionPolicy&& policy,
                        RandomIt first, RandomIt last, Compare cmp );

std::is_heap_until
最小/最大操作
并行化算法 现有算法
模板< ExecutionPolicy, ForwardIt >

ForwardIt max_element( ExecutionPolicy&& policy,
                       ForwardIt first, ForwardIt last );

模板< ExecutionPolicy, ForwardIt, Compare >
ForwardIt max_element( ExecutionPolicy&& policy,
                       ForwardIt first, ForwardIt last, Compare cmp );

std::max_element
模板< ExecutionPolicy, ForwardIt >

ForwardIt min_element( ExecutionPolicy&& policy,
                       ForwardIt first, ForwardIt last );

模板< ExecutionPolicy, ForwardIt, Compare >
ForwardIt min_element( ExecutionPolicy&& policy,
                       ForwardIt first, ForwardIt last, Compare cmp );

std::min_element
模板< ExecutionPolicy, ForwardIt >

std::pair<ForwardIt,ForwardIt>
    minmax_element( ExecutionPolicy&& policy,
                    ForwardIt first, ForwardIt last );

模板< ExecutionPolicy, ForwardIt, Compare >
std::pair<ForwardIt,ForwardIt>
    minmax_element( ExecutionPolicy&& policy,
                    ForwardIt first, ForwardIt last, Compare cmp );

std::minmax_element
模板< ExecutionPolicy, InputIt1, InputIt2 >

布尔 lexicographical_compare( ExecutionPolicy&& policy,
                              InputIt1 first1, InputIt1 last1,
                              InputIt2 first2, InputIt2 last2 );

模板< ExecutionPolicy, InputIt1,
          InputIt2, Compare >
布尔 lexicographical_compare( ExecutionPolicy&& policy,
                              InputIt1 first1, InputIt1 last1,
                              InputIt2 first2, InputIt2 last2,
                              Compare cmp );

std::lexicographical_compare
数值操作
并行化算法 现有算法
template< class ExecutionPolicy, class InputIt, class OutputIt >

OutputIt adjacent_difference( ExecutionPolicy&& policy,
                              InputIt first, InputIt last,
                              OutputIt d_first );

template< class ExecutionPolicy, class InputIt,
          class OutputIt, class BinaryOp >
OutputIt adjacent_difference( ExecutionPolicy&& policy,
                              InputIt first, InputIt last,
                              OutputIt d_first, BinaryOp op );

std::adjacent_difference
template< class ExecutionPolicy, class InputIt1,

          class InputIt2, class T >
T inner_product( ExecutionPolicy&& policy,
                 InputIt1 first1, InputIt1 last1, InputIt2 first2,
                 T value );

template< class ExecutionPolicy, class InputIt1, class InputIt2,
          class T, class BinaryOp1, class BinaryOp2 >
T inner_product( ExecutionPolicy&& policy,
                 InputIt1 first1, InputIt1 last1, InputIt2 first2,
                 T value, BinaryOp1 op1, BinaryOp2 op2 );

std::inner_product
未初始化内存上的操作
并行化算法 现有算法
template< class ExecutionPolicy, class InputIt, class ForwardIt >

ForwardIt uninitialized_copy( ExecutionPolicy&& policy,
                              InputIt first, InputIt last,
                              ForwardIt d_first );

std::uninitialized_copy
template< class ExecutionPolicy, class InputIt,

          class Size, class ForwardIt >
ForwardIt uninitialized_copy_n( ExecutionPolicy&& policy,
                                InputIt first, Size count,
                                ForwardIt d_first );

std::uninitialized_copy_n
template< class ExecutionPolicy, class ForwardIt, class T >

void uninitialized_fill( ExecutionPolicy&& policy,
                         ForwardIt first, ForwardIt last,
                         const T& value );

std::uninitialized_fill
template< class ExecutionPolicy, class ForwardIt, class Size, class T >

ForwardIt uninitialized_fill_n( ExecutionPolicy&& policy,
                                ForwardIt first, Size count,
                                const T& value );

std::uninitialized_fill_n