FastLED 3.9.15
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 417 of file cstdlib.cpp.hpp.

417 {
418 if (nmemb <= 1) {
419 return;
420 }
421
422 // Use insertion sort for small arrays (threshold of 16)
423 if (nmemb <= 16) {
424 qsort_insertion_sort(base, nmemb, size, compar);
425 return;
426 }
427
428 size_t pivot_idx = qsort_partition(base, nmemb, size, compar);
429
430 // Sort left partition
431 qsort_impl(base, pivot_idx, size, compar);
432
433 // Sort right partition
434 if (pivot_idx + 1 < nmemb) {
435 qsort_impl(base + (pivot_idx + 1) * size, nmemb - pivot_idx - 1, size, compar);
436 }
437}
void qsort_impl(char *base, size_t nmemb, size_t size, qsort_compare_fn compar)
static size_t qsort_partition(char *base, size_t nmemb, size_t size, qsort_compare_fn compar)
static void qsort_insertion_sort(char *base, size_t nmemb, size_t size, qsort_compare_fn compar)

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

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

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