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

684 {
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}
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: