9template <
typename Iterator,
typename Compare>
10void sift_down(Iterator first, Iterator last, Iterator start, Compare comp) {
12 auto child = first + 2 * (root - first) + 1;
14 while (child < last) {
15 if (child + 1 < last && comp(*child, *(child + 1))) {
19 if (comp(*root, *child)) {
25 child = first + 2 * (root - first) + 1;
32template <
typename Iterator,
typename Compare>
33void push_heap(Iterator first, Iterator last, Compare comp) {
35 auto parent = first + ((
pos - first) - 1) / 2;
37 while (
pos > first && comp(*parent, *
pos)) {
43 parent = first + ((
pos - first) - 1) / 2;
47template <
typename Iterator>
void push_heap(Iterator first, Iterator last) {
48 push_heap(first, last, [](
const auto &a,
const auto &b) {
return a < b; });
51template <
typename Iterator,
typename Compare>
52void pop_heap(Iterator first, Iterator last, Compare comp) {
61template <
typename Iterator>
void pop_heap(Iterator first, Iterator last) {
62 pop_heap(first, last, [](
const auto &a,
const auto &b) {
return a < b; });
65template <
typename T,
typename Compare = fl::less<T>,
66 typename VectorT = fl::HeapVector<T>>
76 void push(
const T &value) {
77 _data.push_back(value);
PriorityQueue(const Compare &comp)
const Compare & compare() const
void push(const T &value)
void sift_down(Iterator first, Iterator last, Iterator start, Compare comp)
void pop_heap(Iterator first, Iterator last, Compare comp)
void push_heap(Iterator first, Iterator last, Compare comp)
Implements a simple red square effect for 2D LED grids.