FastLED 3.10.10
Loading...
Searching...
No Matches
algorithm.h
Go to the documentation of this file.
1#pragma once
2
5#include "fl/stl/move.h"
6#include "fl/math/random.h"
7#include "fl/stl/noexcept.h"
8
9namespace fl {
10
11namespace adl_barrier { // see fl/stl/adl_barrier.h
12
13template <typename Iterator>
14void reverse(Iterator first, Iterator last) FL_NO_EXCEPT {
15 while ((first != last) && (first != --last)) {
16 swap(*first++, *last);
17 }
18}
19
20template <typename Iterator>
21Iterator max_element(Iterator first, Iterator last) FL_NO_EXCEPT {
22 if (first == last) {
23 return last;
24 }
25
26 Iterator max_iter = first;
27 ++first;
28
29 while (first != last) {
30 if (*max_iter < *first) {
31 max_iter = first;
32 }
33 ++first;
34 }
35
36 return max_iter;
37}
38
39template <typename Iterator, typename Compare>
40Iterator max_element(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
41 if (first == last) {
42 return last;
43 }
44
45 Iterator max_iter = first;
46 ++first;
47
48 while (first != last) {
49 if (comp(*max_iter, *first)) {
50 max_iter = first;
51 }
52 ++first;
53 }
54
55 return max_iter;
56}
57
58template <typename Iterator>
59Iterator min_element(Iterator first, Iterator last) FL_NO_EXCEPT {
60 if (first == last) {
61 return last;
62 }
63
64 Iterator min_iter = first;
65 ++first;
66
67 while (first != last) {
68 if (*first < *min_iter) {
69 min_iter = first;
70 }
71 ++first;
72 }
73
74 return min_iter;
75}
76
77template <typename Iterator, typename Compare>
78Iterator min_element(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
79 if (first == last) {
80 return last;
81 }
82
83 Iterator min_iter = first;
84 ++first;
85
86 while (first != last) {
87 if (comp(*first, *min_iter)) {
88 min_iter = first;
89 }
90 ++first;
91 }
92
93 return min_iter;
94}
95
96
97
98template <typename Iterator1, typename Iterator2>
99bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2) FL_NO_EXCEPT {
100 while (first1 != last1) {
101 if (*first1 != *first2) {
102 return false;
103 }
104 ++first1;
105 ++first2;
106 }
107 return true;
108}
109
110template <typename Iterator1, typename Iterator2, typename BinaryPredicate>
111bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2, BinaryPredicate pred) FL_NO_EXCEPT {
112 while (first1 != last1) {
113 if (!pred(*first1, *first2)) {
114 return false;
115 }
116 ++first1;
117 ++first2;
118 }
119 return true;
120}
121
122template <typename Iterator1, typename Iterator2>
123bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2) FL_NO_EXCEPT {
124 while (first1 != last1 && first2 != last2) {
125 if (*first1 != *first2) {
126 return false;
127 }
128 ++first1;
129 ++first2;
130 }
131 return first1 == last1 && first2 == last2;
132}
133
134template <typename Iterator1, typename Iterator2, typename BinaryPredicate>
135bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, BinaryPredicate pred) FL_NO_EXCEPT {
136 while (first1 != last1 && first2 != last2) {
137 if (!pred(*first1, *first2)) {
138 return false;
139 }
140 ++first1;
141 ++first2;
142 }
143 return first1 == last1 && first2 == last2;
144}
145
146// Lexicographical comparison - compares two ranges element by element
147// Returns true if the first range is lexicographically less than the second
148template <typename Iterator1, typename Iterator2>
149bool lexicographical_compare(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2) FL_NO_EXCEPT {
150 while (first1 != last1 && first2 != last2) {
151 if (*first1 < *first2) {
152 return true;
153 }
154 if (*first2 < *first1) {
155 return false;
156 }
157 ++first1;
158 ++first2;
159 }
160 // If we've exhausted first1 but not first2, first1 is less
161 // If we've exhausted both, they're equal (return false)
162 // If we've exhausted first2 but not first1, first2 is less (return false)
163 return (first1 == last1) && (first2 != last2);
164}
165
166// Lexicographical comparison with custom comparator
167template <typename Iterator1, typename Iterator2, typename Compare>
168bool lexicographical_compare(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, Compare comp) FL_NO_EXCEPT {
169 while (first1 != last1 && first2 != last2) {
170 if (comp(*first1, *first2)) {
171 return true;
172 }
173 if (comp(*first2, *first1)) {
174 return false;
175 }
176 ++first1;
177 ++first2;
178 }
179 // If we've exhausted first1 but not first2, first1 is less
180 // If we've exhausted both, they're equal (return false)
181 // If we've exhausted first2 but not first1, first2 is less (return false)
182 return (first1 == last1) && (first2 != last2);
183}
184
185template <typename Container1, typename Container2>
186bool equal_container(const Container1& c1, const Container2& c2) FL_NO_EXCEPT {
187 fl::size size1 = c1.size();
188 fl::size size2 = c2.size();
189 if (size1 != size2) {
190 return false;
191 }
192 return equal(c1.begin(), c1.end(), c2.begin(), c2.end());
193}
194
195template <typename Container1, typename Container2, typename BinaryPredicate>
196bool equal_container(const Container1& c1, const Container2& c2, BinaryPredicate pred) FL_NO_EXCEPT {
197 fl::size size1 = c1.size();
198 fl::size size2 = c2.size();
199 if (size1 != size2) {
200 return false;
201 }
202 return equal(c1.begin(), c1.end(), c2.begin(), c2.end(), pred);
203}
204
205
206template <typename Iterator, typename T>
207void fill(Iterator first, Iterator last, const T& value) FL_NO_EXCEPT {
208 while (first != last) {
209 *first = value;
210 ++first;
211 }
212}
213
214template <typename Iterator, typename T>
215Iterator find(Iterator first, Iterator last, const T& value) FL_NO_EXCEPT {
216 while (first != last) {
217 if (*first == value) {
218 return first;
219 }
220 ++first;
221 }
222 return last;
223}
224
225template <typename Iterator, typename UnaryPredicate>
226Iterator find_if(Iterator first, Iterator last, UnaryPredicate pred) FL_NO_EXCEPT {
227 while (first != last) {
228 if (pred(*first)) {
229 return first;
230 }
231 ++first;
232 }
233 return last;
234}
235
236template <typename Iterator, typename UnaryPredicate>
237Iterator find_if_not(Iterator first, Iterator last, UnaryPredicate pred) FL_NO_EXCEPT {
238 while (first != last) {
239 if (!pred(*first)) {
240 return first;
241 }
242 ++first;
243 }
244 return last;
245}
246
247template <typename Iterator, typename T>
248void replace(Iterator first, Iterator last, const T& old_value, const T& new_value) FL_NO_EXCEPT {
249 while (first != last) {
250 if (*first == old_value) {
251 *first = new_value;
252 }
253 ++first;
254 }
255}
256
257template <typename Iterator, typename UnaryPredicate, typename T>
258void replace_if(Iterator first, Iterator last, UnaryPredicate pred, const T& new_value) FL_NO_EXCEPT {
259 while (first != last) {
260 if (pred(*first)) {
261 *first = new_value;
262 }
263 ++first;
264 }
265}
266
267template <typename Iterator, typename T>
268Iterator remove(Iterator first, Iterator last, const T& value) FL_NO_EXCEPT {
269 Iterator result = first;
270 while (first != last) {
271 if (!(*first == value)) {
272 if (result != first) {
273 *result = fl::move(*first);
274 }
275 ++result;
276 }
277 ++first;
278 }
279 return result;
280}
281
282template <typename Iterator, typename UnaryPredicate>
283Iterator remove_if(Iterator first, Iterator last, UnaryPredicate pred) FL_NO_EXCEPT {
284 Iterator result = first;
285 while (first != last) {
286 if (!pred(*first)) {
287 if (result != first) {
288 *result = fl::move(*first);
289 }
290 ++result;
291 }
292 ++first;
293 }
294 return result;
295}
296
297} // namespace adl_barrier
298
299namespace detail {
300
301// Insertion sort implementation for small arrays
302template <typename Iterator, typename Compare>
303void insertion_sort(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
304 if (first == last) return;
305
306 for (Iterator i = first + 1; i != last; ++i) {
307 auto value = fl::move(*i);
308 Iterator j = i;
309
310 while (j != first && comp(value, *(j - 1))) {
311 *j = fl::move(*(j - 1));
312 --j;
313 }
314
315 *j = fl::move(value);
316 }
317}
318
319// Median-of-three pivot selection
320template <typename Iterator, typename Compare>
321Iterator median_of_three(Iterator first, Iterator middle, Iterator last, Compare comp) FL_NO_EXCEPT {
322 if (comp(*middle, *first)) {
323 if (comp(*last, *middle)) {
324 return middle;
325 } else if (comp(*last, *first)) {
326 return last;
327 } else {
328 return first;
329 }
330 } else {
331 if (comp(*last, *first)) {
332 return first;
333 } else if (comp(*last, *middle)) {
334 return last;
335 } else {
336 return middle;
337 }
338 }
339}
340
341// Three-way (Dutch national flag) partition for quicksort.
342// On return: [first, lt) < pivot, [lt, gt) == pivot, [gt, last) > pivot.
343// Grouping equal keys in the middle keeps duplicate-heavy input O(n log n);
344// a two-way Lomuto partition put every equal key on one side and went O(n^2).
345// The pivot element itself is tracked at *lt, so no value copy is needed.
346template <typename Iterator, typename Compare>
347void partition3(Iterator first, Iterator last, Compare comp,
348 Iterator& lt_out, Iterator& gt_out) FL_NO_EXCEPT {
349 Iterator middle = first + (last - first) / 2;
350 Iterator pivot_iter = median_of_three(first, middle, last - 1, comp);
351 swap(*first, *pivot_iter);
352
353 Iterator lt = first; // *lt is always a pivot-equal element
354 Iterator i = first + 1;
355 Iterator gt = last;
356 while (i < gt) {
357 if (comp(*i, *lt)) {
358 swap(*lt, *i);
359 ++lt;
360 ++i;
361 } else if (comp(*lt, *i)) {
362 --gt;
363 swap(*i, *gt);
364 } else {
365 ++i;
366 }
367 }
368 lt_out = lt;
369 gt_out = gt;
370}
371
372// Heapsort implementation (fallback for deep recursion)
373template <typename Iterator, typename Compare>
374void sift_down(Iterator first, Iterator start, Iterator end, Compare comp) FL_NO_EXCEPT {
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}
398
399template <typename Iterator, typename Compare>
400void heapify(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
401 Iterator start = first + (last - first - 2) / 2;
402
403 while (true) {
404 detail::sift_down(first, start, last - 1, comp);
405 if (start == first) {
406 break;
407 }
408 --start;
409 }
410}
411
412template <typename Iterator, typename Compare>
413void heap_sort(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
414 heapify(first, last, comp);
415
416 Iterator end = last - 1;
417 while (end > first) {
418 swap(*end, *first);
419 detail::sift_down(first, first, end - 1, comp);
420 --end;
421 }
422}
423
424// Introsort: three-way quicksort that recurses into the smaller side and
425// loops on the larger (stack depth <= log2(n)), and falls back to heap_sort
426// once the partition depth exceeds ~2*log2(n) (worst case O(n log n)).
427template <typename Iterator, typename Compare>
428void quicksort_impl(Iterator first, Iterator last, Compare comp,
429 int depth_limit) FL_NO_EXCEPT {
430 while (last - first > 16) {
431 if (depth_limit <= 0) {
432 detail::heap_sort(first, last, comp);
433 return;
434 }
435 --depth_limit;
436 Iterator lt;
437 Iterator gt;
438 detail::partition3(first, last, comp, lt, gt);
439 if (lt - first < last - gt) {
440 detail::quicksort_impl(first, lt, comp, depth_limit);
441 first = gt;
442 } else {
443 detail::quicksort_impl(gt, last, comp, depth_limit);
444 last = lt;
445 }
446 }
447 insertion_sort(first, last, comp);
448}
449
450template <typename Iterator, typename Compare>
451void quicksort_impl(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
452 int depth_limit = 0;
453 for (auto n = last - first; n > 1; n >>= 1) {
454 depth_limit += 2;
455 }
456 detail::quicksort_impl(first, last, comp, depth_limit);
457}
458
459// Rotate elements in range [first, last) so that middle becomes the new first
460template <typename Iterator>
461void rotate_impl(Iterator first, Iterator middle, Iterator last) FL_NO_EXCEPT {
462 if (first == middle || middle == last) {
463 return;
464 }
465
466 Iterator next = middle;
467 while (first != next) {
468 swap(*first++, *next++);
469 if (next == last) {
470 next = middle;
471 } else if (first == middle) {
472 middle = next;
473 }
474 }
475}
476
477// Find the position where value should be inserted in sorted range [first, last)
478template <typename Iterator, typename T, typename Compare>
479Iterator lower_bound_impl(Iterator first, Iterator last, const T& value, Compare comp) FL_NO_EXCEPT {
480 auto count = last - first;
481 while (count > 0) {
482 auto step = count / 2;
483 Iterator it = first + step;
484 if (comp(*it, value)) {
485 first = ++it;
486 count -= step + 1;
487 } else {
488 count = step;
489 }
490 }
491 return first;
492}
493
494// In-place merge operation for merge sort (stable sort)
495template <typename Iterator, typename Compare>
496void merge_inplace(Iterator first, Iterator middle, Iterator last, Compare comp) FL_NO_EXCEPT {
497 // If one of the ranges is empty, nothing to merge
498 if (first == middle || middle == last) {
499 return;
500 }
501
502 // If arrays are small enough, use insertion-based merge
503 auto left_size = middle - first;
504 auto right_size = last - middle;
505 if (left_size + right_size <= 32) {
506 // Simple insertion-based merge for small arrays
507 Iterator left = first;
508 Iterator right = middle;
509
510 while (left < middle && right < last) {
511 if (!comp(*right, *left)) {
512 // left element is in correct position
513 ++left;
514 } else {
515 // right element needs to be inserted into left part
516 auto value = fl::move(*right);
517 Iterator shift_end = right;
518 Iterator shift_start = left;
519
520 // Shift elements to make room
521 while (shift_end > shift_start) {
522 *shift_end = fl::move(*(shift_end - 1));
523 --shift_end;
524 }
525
526 *left = fl::move(value);
527 ++left;
528 ++middle; // middle has shifted right
529 ++right;
530 }
531 }
532 return;
533 }
534
535 // For larger arrays, use rotation-based merge
536 if (left_size == 0 || right_size == 0) {
537 return;
538 }
539
540 if (left_size == 1) {
541 // Find insertion point for the single left element in right array
542 Iterator pos = lower_bound_impl(middle, last, *first, comp);
543 rotate_impl(first, middle, pos);
544 return;
545 }
546
547 if (right_size == 1) {
548 // Find insertion point for the single right element in left array
549 Iterator pos = lower_bound_impl(first, middle, *(last - 1), comp);
550 rotate_impl(pos, middle, last);
551 return;
552 }
553
554 // Divide both arrays and recursively merge
555 Iterator left_mid = first + left_size / 2;
556 Iterator right_mid = lower_bound_impl(middle, last, *left_mid, comp);
557
558 // Rotate to bring the two middle parts together
559 rotate_impl(left_mid, middle, right_mid);
560
561 // Update middle position
562 Iterator new_middle = left_mid + (right_mid - middle);
563
564 // Recursively merge the two parts
565 merge_inplace(first, left_mid, new_middle, comp);
566 merge_inplace(new_middle, right_mid, last, comp);
567}
568
569// Merge sort implementation (stable, in-place)
570template <typename Iterator, typename Compare>
571void mergesort_impl(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
572 auto size = last - first;
573 if (size <= 16) { // Use insertion sort for small arrays (it's stable)
574 insertion_sort(first, last, comp);
575 return;
576 }
577
578 Iterator middle = first + size / 2;
579 mergesort_impl(first, middle, comp);
580 mergesort_impl(middle, last, comp);
581 merge_inplace(first, middle, last, comp);
582}
583
584} // namespace detail
585
586namespace adl_barrier { // see fl/stl/adl_barrier.h
587
588// Lower bound: find first position in sorted [first, last) where value could be inserted.
589template <typename Iterator, typename T, typename Compare>
590Iterator lower_bound(Iterator first, Iterator last, const T& value, Compare comp) FL_NO_EXCEPT {
591 return detail::lower_bound_impl(first, last, value, comp);
592}
593
594template <typename Iterator, typename T>
595Iterator lower_bound(Iterator first, Iterator last, const T& value) FL_NO_EXCEPT {
596 typedef typename fl::remove_reference<decltype(*first)>::type value_type;
597 return detail::lower_bound_impl(first, last, value,
598 [](const value_type& a, const T& b) { return a < b; });
599}
600
601// Sort function with custom comparator (using quicksort)
602template <typename Iterator, typename Compare>
603void sort(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
604 if (first == last || first + 1 == last) {
605 return; // Already sorted or empty
606 }
607
608 detail::quicksort_impl(first, last, comp);
609}
610
611// Sort function with default comparator
612template <typename Iterator>
613void sort(Iterator first, Iterator last) FL_NO_EXCEPT {
614 // Use explicit template parameter to avoid C++14 auto in lambda
615 typedef typename fl::remove_reference<decltype(*first)>::type value_type;
616 sort(first, last, [](const value_type& a, const value_type& b) { return a < b; });
617}
618
619// Stable sort function with custom comparator (using merge sort)
620template <typename Iterator, typename Compare>
621void stable_sort(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
622 if (first == last || first + 1 == last) {
623 return; // Already sorted or empty
624 }
625
626 detail::mergesort_impl(first, last, comp);
627}
628
629// Stable sort function with default comparator
630template <typename Iterator>
631void stable_sort(Iterator first, Iterator last) FL_NO_EXCEPT {
632 // Use explicit template parameter to avoid C++14 auto in lambda
633 typedef typename fl::remove_reference<decltype(*first)>::type value_type;
634 stable_sort(first, last, [](const value_type& a, const value_type& b) { return a < b; });
635}
636
637// Direct call to insertion sort — meant for call sites with statically
638// bounded input (typically <= 16-32 elements). Skips the runtime fall-through
639// inside `quicksort_impl`, so the compiler does NOT instantiate the
640// quicksort + partition + heap_sort body at all. Per-instantiation savings
641// land in the function symbol that anchors the static-init chain
642// (`ClocklessIdf5` on ESP32-S3). See #2886 / #2907.
643//
644// Use `sort_small` when:
645// - the container's max size is bounded by construction (e.g. fl::vector_inlined<T, N>)
646// and N is small (rule of thumb: <= 32);
647// - O(n^2) worst-case is acceptable.
648//
649// Use `fl::sort` (quicksort) when the container is unbounded or large.
650template <typename Iterator, typename Compare>
651void sort_small(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {
652 if (first == last || first + 1 == last) {
653 return; // Already sorted or empty
654 }
655 detail::insertion_sort(first, last, comp);
656}
657
658template <typename Iterator>
659void sort_small(Iterator first, Iterator last) FL_NO_EXCEPT {
660 typedef typename fl::remove_reference<decltype(*first)>::type value_type;
661 sort_small(first, last,
662 [](const value_type& a, const value_type& b) { return a < b; });
663}
664
665// Shuffle function with custom random generator (Fisher-Yates shuffle)
666template <typename Iterator, typename RandomGenerator>
667void shuffle(Iterator first, Iterator last, RandomGenerator& g) FL_NO_EXCEPT {
668 if (first == last) {
669 return; // Empty range, nothing to shuffle
670 }
671
672 auto n = last - first;
673 for (auto i = n - 1; i > 0; --i) {
674 // Generate random index from 0 to i (inclusive)
675 auto j = g() % (i + 1);
676
677 // Swap elements at positions i and j
678 swap(*(first + i), *(first + j));
679 }
680}
681
682// Shuffle function with fl::math::random instance
683template <typename Iterator>
684void shuffle(Iterator first, Iterator last, math::random& rng) FL_NO_EXCEPT {
685 if (first == last) {
686 return; // Empty range, nothing to shuffle
687 }
688
689 auto n = last - first;
690 for (auto i = n - 1; i > 0; --i) {
691 // Generate random index from 0 to i (inclusive)
692 auto j = rng(static_cast<u32>(i + 1));
693
694 // Swap elements at positions i and j
695 swap(*(first + i), *(first + j));
696 }
697}
698
699// Shuffle function with default random generator
700template <typename Iterator>
701void shuffle(Iterator first, Iterator last) FL_NO_EXCEPT {
702 shuffle(first, last, default_random());
703}
704
705} // namespace adl_barrier
706
707} // namespace fl
uint8_t pos
Definition Blur.ino:11
Keeps fl's generic templates out of argument-dependent lookup (ADL).
A random number generator class that wraps FastLED's random functions.
Definition random.h:25
void replace(Iterator first, Iterator last, const T &old_value, const T &new_value) FL_NO_EXCEPT
Definition algorithm.h:248
constexpr T * end(T(&array)[N]) FL_NO_EXCEPT
Iterator remove_if(Iterator first, Iterator last, UnaryPredicate pred) FL_NO_EXCEPT
Definition algorithm.h:283
Iterator max_element(Iterator first, Iterator last) FL_NO_EXCEPT
Definition algorithm.h:21
Iterator lower_bound(Iterator first, Iterator last, const T &value, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:590
bool equal_container(const Container1 &c1, const Container2 &c2) FL_NO_EXCEPT
Definition algorithm.h:186
Iterator find_if_not(Iterator first, Iterator last, UnaryPredicate pred) FL_NO_EXCEPT
Definition algorithm.h:237
Iterator min_element(Iterator first, Iterator last) FL_NO_EXCEPT
Definition algorithm.h:59
void sort_small(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:651
Iterator find_if(Iterator first, Iterator last, UnaryPredicate pred) FL_NO_EXCEPT
Definition algorithm.h:226
void replace_if(Iterator first, Iterator last, UnaryPredicate pred, const T &new_value) FL_NO_EXCEPT
Definition algorithm.h:258
bool lexicographical_compare(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2) FL_NO_EXCEPT
Definition algorithm.h:149
void sort(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:603
void fill(Iterator first, Iterator last, const T &value) FL_NO_EXCEPT
Definition algorithm.h:207
void stable_sort(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:621
Iterator remove(Iterator first, Iterator last, const T &value) FL_NO_EXCEPT
Definition algorithm.h:268
bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2) FL_NO_EXCEPT
Definition algorithm.h:99
void reverse(Iterator first, Iterator last) FL_NO_EXCEPT
Definition algorithm.h:14
Iterator find(Iterator first, Iterator last, const T &value) FL_NO_EXCEPT
Definition algorithm.h:215
void shuffle(Iterator first, Iterator last, RandomGenerator &g) FL_NO_EXCEPT
Definition algorithm.h:667
void mergesort_impl(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:571
void rotate_impl(Iterator first, Iterator middle, Iterator last) FL_NO_EXCEPT
Definition algorithm.h:461
Iterator lower_bound_impl(Iterator first, Iterator last, const T &value, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:479
void heapify(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:400
void sift_down(Iterator first, Iterator start, Iterator end, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:374
Iterator median_of_three(Iterator first, Iterator middle, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:321
void quicksort_impl(Iterator first, Iterator last, Compare comp, int depth_limit) FL_NO_EXCEPT
Definition algorithm.h:428
void heap_sort(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:413
void insertion_sort(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:303
void partition3(Iterator first, Iterator last, Compare comp, Iterator &lt_out, Iterator &gt_out) FL_NO_EXCEPT
Definition algorithm.h:347
void merge_inplace(Iterator first, Iterator middle, Iterator last, Compare comp) FL_NO_EXCEPT
Definition algorithm.h:496
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition s16x16x4.h:30
void swap(array< T, N > &lhs, array< T, N > &rhs) FL_NO_EXCEPT
Definition array.h:209
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
constexpr int type_rank< T >::value
math::random & default_random() FL_NO_EXCEPT
Global default random number generator instance.
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
constexpr enable_if< is_fixed_point< T >::value, T >::type step(T edge, T x) FL_NO_EXCEPT
InputGamut g
Definition rgbw.h:125
Base definition for an LED controller.