next method

Stream<int> next({
  1. int? maxCount,
})

The method updates the state using the MWC algorithm and returns the next 32-bit random number. https://docs.opencv.org/4.x/d1/dd6/classcv_1_1RNG.html#ad8d035897a5e31e7fc3e1e6c378c32f5

Implementation

Stream<int> next({int? maxCount}) async* {
  int count = 0;
  final p = calloc<ffi.Uint32>();
  try {
    while (true) {
      cvRun(() => ccore.RNG_Next(ref, p));
      yield p.value;

      count++;
      if (maxCount != null && ++count >= maxCount) break;
    }
  } finally {
    calloc.free(p);
  }
}