| 148 | /** @ingroup algorithms */ |
| 149 | template<typename RandomAccessIterator, typename Compare> |
| 150 | void parallel_quick_sort( RandomAccessIterator begin, RandomAccessIterator end, const Compare& comp ) { |
| 151 | #if __TBB_TASK_GROUP_CONTEXT |
| 152 | task_group_context my_context; |
| 153 | const int serial_cutoff = 9; |
| 154 | |
| 155 | __TBB_ASSERT( begin + serial_cutoff < end, "min_parallel_size is smaller than serial cutoff?" ); |
| 156 | RandomAccessIterator k; |
| 157 | for ( k = begin ; k != begin + serial_cutoff; ++k ) { |
| 158 | if ( comp( *(k+1), *k ) ) { |
| 159 | goto do_parallel_quick_sort; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | parallel_for( blocked_range<RandomAccessIterator>(k+1, end), |
| 164 | quick_sort_pretest_body<RandomAccessIterator,Compare>(comp), |
| 165 | auto_partitioner(), |
| 166 | my_context); |
| 167 | |
| 168 | if (my_context.is_group_execution_cancelled()) |
| 169 | do_parallel_quick_sort: |
| 170 | #endif /* __TBB_TASK_GROUP_CONTEXT */ |
| 171 | parallel_for( quick_sort_range<RandomAccessIterator,Compare>(begin, end-begin, comp ), |
| 172 | quick_sort_body<RandomAccessIterator,Compare>(), |
| 173 | auto_partitioner() ); |
| 174 | } |
| 175 | |
| 176 | } // namespace internal |
| 177 | //! @endcond |
no test coverage detected