共用方式為


parallel_buffered_sort 函式

為一種 nondescending 的順序,或根據指定的二元述詞,以平行方式排序準則,請將排列在指定範圍中的項目。 這個函式是語意上類似於std::sort ,因為它是指以比較為基礎、 不穩定、 就地的形式,不同之處在於它需要**O(n)**的額外空間,而且需要預設值初始化正在排序之項目的。

template<
   typename _Random_iterator
>
inline void parallel_buffered_sort(
   const _Random_iterator &_Begin,
   const _Random_iterator &_End
);

template<
   typename _Allocator,
   typename _Random_iterator
>
inline void parallel_buffered_sort(
   const _Random_iterator &_Begin,
   const _Random_iterator &_End
);

template<
   typename _Allocator,
   typename _Random_iterator
>
inline void parallel_buffered_sort(
   const _Allocator& _Alloc,
   const _Random_iterator &_Begin,
   const _Random_iterator &_End
);

template<
   typename _Random_iterator,
   typename _Function
>
inline void parallel_buffered_sort(
   const _Random_iterator &_Begin,
   const _Random_iterator &_End,
   const _Function &_Func,
   const size_t _Chunk_size = 2048
);

template<
   typename _Allocator,
   typename _Random_iterator,
   typename _Function
>
inline void parallel_buffered_sort(
   const _Random_iterator &_Begin,
   const _Random_iterator &_End,
   const _Function &_Func,
   const size_t _Chunk_size = 2048
);

template<
   typename _Allocator,
   typename _Random_iterator,
   typename _Function
>
inline void parallel_buffered_sort(
   const _Allocator& _Alloc,
   const _Random_iterator &_Begin,
   const _Random_iterator &_End,
   const _Function &_Func,
   const size_t _Chunk_size = 2048
);

參數

  • _Random_iterator
    Iterator 的類型與輸入範圍。

  • _Allocator
    STL 相容的記憶體配置器的型別。

  • _Function
    二進位比較運算子的型別。

  • _Begin
    隨機存取 iterator 定址中範圍的第一個元素的位置會依序排列。

  • _End
    隨機存取 iterator 定址位置 1,超過範圍中的最後一個元素會依序排列。

  • _Alloc
    STL 相容的記憶體配置器的執行個體。

  • _Func
    使用者定義述詞函式物件定義的比較準則,以滿足由連續的項目中的順序。 二元述詞會接受兩個引數,並傳回true滿足時, false未能滿足時。 這個比較運算子函式必須加上嚴格弱式順序上成對的序列中項目。

  • _Chunk_size
    Mimimum 會分割成兩個平行處理執行之區塊的大小。

備註

所有多載必須有n * sizeof(T)的額外空間,其中n是要排序的項目數,並T是元素型別。 在大多數情況下 parallel_buffered_sort 會顯示一項改進效能變動 parallel_sort,而且您應該在使用它 parallel_sort 如果您有可用的記憶體。

如果您不提供二進位比較運算子std::less做為預設值,而這會提供運算子的元素型別operator<()

如果您不提供配置器類型或例項,STL 記憶體配置器**std::allocator<T>**用來配置的緩衝區。

演算法會將輸入的範圍分割成兩個區塊 (chunk),而且連續分為兩個 sub-chunks 以平行方式執行中的每個區塊。 選擇性的引數_Chunk_size可以用來向演算法它應該處理區塊 (chunk) 大小的 < _Chunk_size以序列方式。

需求

標頭: ppl.h

Namespace: 並行存取

請參閱

參考

concurrency 命名空間