FastLED 3.9.15
Loading...
Searching...
No Matches
fl::math::random Class Reference

Detailed Description

A random number generator class that wraps FastLED's random functions.

This class provides a standard C++ random generator interface that can be used with algorithms like fl::shuffle. Each instance maintains its own seed state independent of other instances and the global FastLED random state.

All public methods delegate to private _nolock helpers. This means external locking (via the LockedRandom singleton in random.cpp.hpp) only needs to wrap the public entry points.

fl::vector<int> vec = {1, 2, 3, 4, 5};
fl::shuffle(vec.begin(), vec.end(), rng);
A random number generator class that wraps FastLED's random functions.
Definition random.h:25
iterator begin() FL_NOEXCEPT
Definition vector.h:655
iterator end() FL_NOEXCEPT
Definition vector.h:661
void shuffle(Iterator first, Iterator last, RandomGenerator &g) FL_NOEXCEPT
Definition algorithm.h:628

Definition at line 25 of file random.h.

#include <random.h>

Public Types

typedef u32 result_type
 

Public Member Functions

 random () FL_NOEXCEPT
 Default constructor - uses current global random seed.
 
 random (u16 seed) FL_NOEXCEPT
 Constructor with explicit seed.
 
void add_entropy (u16 entropy) FL_NOEXCEPT
 
u16 get_seed () const FL_NOEXCEPT
 
result_type operator() () FL_NOEXCEPT
 
result_type operator() (result_type min, result_type max) FL_NOEXCEPT
 
result_type operator() (result_type n) FL_NOEXCEPT
 
u16 random16 () FL_NOEXCEPT
 
u16 random16 (u16 min, u16 max) FL_NOEXCEPT
 
u16 random16 (u16 n) FL_NOEXCEPT
 
u8 random8 () FL_NOEXCEPT
 
u8 random8 (u8 min, u8 max) FL_NOEXCEPT
 
u8 random8 (u8 n) FL_NOEXCEPT
 
void set_seed (u16 seed) FL_NOEXCEPT
 

Static Public Member Functions

static constexpr result_type maximum () FL_NOEXCEPT
 
static constexpr result_type minimum () FL_NOEXCEPT
 

Private Member Functions

result_type generate_nolock () FL_NOEXCEPT
 
result_type generate_nolock (result_type min, result_type max) FL_NOEXCEPT
 
result_type generate_nolock (result_type n) FL_NOEXCEPT
 
u16 next_random16_nolock () FL_NOEXCEPT
 
u32 next_random32_nolock () FL_NOEXCEPT
 
u16 random16_nolock () FL_NOEXCEPT
 
u8 random8_nolock () FL_NOEXCEPT
 
u8 random8_nolock (u8 min, u8 max) FL_NOEXCEPT
 
u8 random8_nolock (u8 n) FL_NOEXCEPT
 

Private Attributes

u16 mSeed
 

The documentation for this class was generated from the following file: