MCPcopy Create free account
hub / github.com/FastLED/FastLED / sift_down

Function sift_down

src/fl/stl/algorithm.h:360–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358// Heapsort implementation (fallback for deep recursion)
359template <typename Iterator, typename Compare>
360void sift_down(Iterator first, Iterator start, Iterator end, Compare comp) FL_NOEXCEPT {
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}
383
384template <typename Iterator, typename Compare>
385void heapify(Iterator first, Iterator last, Compare comp) FL_NOEXCEPT {

Callers 3

heapifyFunction · 0.70
heap_sortFunction · 0.70
FL_TEST_FILEFunction · 0.50

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected