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

◆ sift_down()

template<typename Iterator, typename Compare>
void fl::detail::sift_down ( Iterator first,
Iterator start,
Iterator end,
Compare comp )

Definition at line 365 of file algorithm.h.

365 {
366 Iterator root = start;
367
368 while (root - first <= (end - first - 2) / 2) {
369 Iterator child = first + 2 * (root - first) + 1;
370 Iterator swap_iter = root;
371
372 if (comp(*swap_iter, *child)) {
373 swap_iter = child;
374 }
375
376 if (child + 1 <= end && comp(*swap_iter, *(child + 1))) {
377 swap_iter = child + 1;
378 }
379
380 if (swap_iter == root) {
381 return;
382 } else {
383 swap(*root, *swap_iter);
384 root = swap_iter;
385 }
386 }
387}
constexpr T * end(T(&array)[N]) FL_NO_EXCEPT
void swap(array< T, N > &lhs, array< T, N > &rhs) FL_NO_EXCEPT
Definition array.h:209

References fl::adl_barrier::end(), fl::FL_NO_EXCEPT, and fl::swap().

Referenced by heap_sort(), and heapify().

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