VecU16.generate constructor

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

Implementation

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