flush method

void flush([
  1. int count = 1
])

Flushes (advances and discards) the next count states dynamically.

This is extremely useful for explicitly burning internal generator state, matching C++ engine .discard() method natively.

Implementation

void flush([int count = 1]) {
  if (count < 0) {
    throw ArgumentError('StdRandom mathematically restricts flush to non-negative counts.');
  }
  for (var i = 0; i < count; i++) {
    _generator.nextInt(256); // Burn an arbitrary state shift natively
  }
}