FastLED 3.9.15
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 360 of file algorithm.h.

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

References fl::end(), FL_NOEXCEPT, 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: