FastLED 3.10.8
Loading...
Searching...
No Matches

◆ shuffle() [2/3]

template<typename Iterator>
void fl::adl_barrier::shuffle ( Iterator first,
Iterator last,
math::random & rng )

Definition at line 652 of file algorithm.h.

652 {
653 if (first == last) {
654 return; // Empty range, nothing to shuffle
655 }
656
657 auto n = last - first;
658 for (auto i = n - 1; i > 0; --i) {
659 // Generate random index from 0 to i (inclusive)
660 auto j = rng(static_cast<u32>(i + 1));
661
662 // Swap elements at positions i and j
663 swap(*(first + i), *(first + j));
664 }
665}
void swap(array< T, N > &lhs, array< T, N > &rhs) FL_NO_EXCEPT
Definition array.h:209

References fl::FL_NO_EXCEPT, and fl::swap().

+ Here is the call graph for this function: