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 338 of file algorithm.h.

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

References FL_NOEXCEPT, 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: