range method

int range(
  1. int min,
  2. int max
)

Generates a strictly bounded random integer between min (inclusive) and max (exclusive).

Maps conceptually to C++ std::uniform_int_distribution.

Implementation

int range(int min, int max) {
  if (min >= max) {
    throw ArgumentError('StdRandom mathematically requires min < max.');
  }
  return min + _generator.nextInt(max - min);
}