Random

High-level random number generation utilities.

Overview

Typical use cases:

  • Generating random integers within a specified range.

  • Generating random floating-point numbers within a specified range.

Header

<RaeptorCogs/Random.hpp>

Metadata

Author

Estorc

Version

v1.0

Copyright

Copyright (c) 2025 Estorc MIT License.

Classes

Classes

Class

Description

RaeptorCogs::Singletons::Random

Random singleton class.

class Random

Random singleton class.

Provides random number generation functionalities.

int randInt = RaeptorCogs::Random().getInt(1, 10);
float randFloat = RaeptorCogs::Random().getFloat(0.0f, 1.0f);

Public Functions

Random(const Random&) = delete

Deleted copy constructor.

Random &operator=(const Random&) = delete

Deleted assignment operator.

int getInt(int min, int max)

Generate a random integer in the range [min, max].

int randInt = RaeptorCogs::Random().getInt(1, 10);

Parameters:
  • min – The minimum value (inclusive).

  • max – The maximum value (inclusive).

Returns:

A random integer between min and max.

float getFloat(float min, float max)

Generate a random float in the range [min, max).

float randFloat = RaeptorCogs::Random().getFloat(0.0f, 1.0f);

Parameters:
  • min – The minimum value (inclusive).

  • max – The maximum value (exclusive).

Returns:

A random float between min and max.

Private Functions

Random() = default

Private constructor for the Random singleton.

Private Members

friend SingletonAccessor< Random >