VecI16.generate constructor

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

Implementation

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