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

300 {
301 Iterator root = start;
302
303 while (root - first <= (end - first - 2) / 2) {
304 Iterator child = first + 2 * (root - first) + 1;
305 Iterator swap_iter = root;
306
307 if (comp(*swap_iter, *child)) {
308 swap_iter = child;
309 }
310
311 if (child + 1 <= end && comp(*swap_iter, *(child + 1))) {
312 swap_iter = child + 1;
313 }
314
315 if (swap_iter == root) {
316 return;
317 } else {
318 swap(*root, *swap_iter);
319 root = swap_iter;
320 }
321 }
322}
void swap(array< T, N > &lhs, array< T, N > &rhs) noexcept(noexcept(lhs.swap(rhs)))
Definition array.h:156
constexpr T * end(T(&array)[N]) noexcept

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