VecVecChar.generate constructor

VecVecChar.generate(
  1. int length,
  2. Iterable<int> generator(
    1. int i
    )
)

Implementation

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