VecI32.generate constructor

VecI32.generate(
  1. int length,
  2. int generator(
    1. int i
    )
)

Implementation

factory VecI32.generate(int length, int Function(int i) generator) {
  final pp = calloc<cvg.VecI32>()..ref.length = length;
  pp.ref.ptr = calloc<ffi.Int32>(length);
  for (var i = 0; i < length; i++) {
    final v = generator(i);
    pp.ref.ptr[i] = v;
  }
  return VecI32.fromPointer(pp);
}