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

◆ qsort_impl()

void fl::detail::qsort_impl ( char * base,
size_t nmemb,
size_t size,
qsort_compare_fn compar )

Definition at line 456 of file cstdlib.cpp.hpp.

456 {
457 if (nmemb <= 1) {
458 return;
459 }
460
461 // Use insertion sort for small arrays (threshold of 16)
462 if (nmemb <= 16) {
463 qsort_insertion_sort(base, nmemb, size, compar);
464 return;
465 }
466
467 size_t pivot_idx = qsort_partition(base, nmemb, size, compar);
468
469 // Sort left partition
470 qsort_impl(base, pivot_idx, size, compar);
471
472 // Sort right partition
473 if (pivot_idx + 1 < nmemb) {
474 qsort_impl(base + (pivot_idx + 1) * size, nmemb - pivot_idx - 1, size, compar);
475 }
476}
void qsort_impl(char *base, size_t nmemb, size_t size, qsort_compare_fn compar) FL_NO_EXCEPT
static void qsort_insertion_sort(char *base, size_t nmemb, size_t size, qsort_compare_fn compar) FL_NO_EXCEPT
static size_t qsort_partition(char *base, size_t nmemb, size_t size, qsort_compare_fn compar) FL_NO_EXCEPT

References fl::FL_NO_EXCEPT, qsort_impl(), fl::qsort_insertion_sort(), and fl::qsort_partition().

Referenced by fl::libc_impl::qsort(), and qsort_impl().

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