FastLED 3.10.10
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 374 of file algorithm.h.

374 {
375 Iterator root = start;
376
377 // `end` is inclusive: keep sifting while root has at least a left child.
378 while (2 * (root - first) + 1 <= end - first) {
379 Iterator child = first + 2 * (root - first) + 1;
380 Iterator swap_iter = root;
381
382 if (comp(*swap_iter, *child)) {
383 swap_iter = child;
384 }
385
386 if (child + 1 <= end && comp(*swap_iter, *(child + 1))) {
387 swap_iter = child + 1;
388 }
389
390 if (swap_iter == root) {
391 return;
392 } else {
393 swap(*root, *swap_iter);
394 root = swap_iter;
395 }
396 }
397}
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: