FastLED 3.9.15
Loading...
Searching...
No Matches

◆ partition()

template<typename Iterator, typename Compare>
Iterator fl::detail::partition ( Iterator first,
Iterator last,
Compare comp )

Definition at line 278 of file algorithm.h.

278 {
279 Iterator middle = first + (last - first) / 2;
280 Iterator pivot_iter = median_of_three(first, middle, last - 1, comp);
281
282 // Move pivot to end
283 swap(*pivot_iter, *(last - 1));
284 Iterator pivot = last - 1;
285
286 Iterator i = first;
287 for (Iterator j = first; j != pivot; ++j) {
288 if (comp(*j, *pivot)) {
289 swap(*i, *j);
290 ++i;
291 }
292 }
293
294 swap(*i, *pivot);
295 return i;
296}
Iterator median_of_three(Iterator first, Iterator middle, Iterator last, Compare comp)
Definition algorithm.h:256
void swap(array< T, N > &lhs, array< T, N > &rhs) noexcept(noexcept(lhs.swap(rhs)))
Definition array.h:156

References median_of_three(), and fl::swap().

Referenced by quicksort_impl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: