FastLED 3.10.8
Loading...
Searching...
No Matches

◆ partition()

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

Definition at line 343 of file algorithm.h.

343 {
344 Iterator middle = first + (last - first) / 2;
345 Iterator pivot_iter = median_of_three(first, middle, last - 1, comp);
346
347 // Move pivot to end
348 swap(*pivot_iter, *(last - 1));
349 Iterator pivot = last - 1;
350
351 Iterator i = first;
352 for (Iterator j = first; j != pivot; ++j) {
353 if (comp(*j, *pivot)) {
354 swap(*i, *j);
355 ++i;
356 }
357 }
358
359 swap(*i, *pivot);
360 return i;
361}
Iterator median_of_three(Iterator first, Iterator middle, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:321
void swap(array< T, N > &lhs, array< T, N > &rhs) FL_NO_EXCEPT
Definition array.h:209

References fl::FL_NO_EXCEPT, 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: