VectorList<T extends Vector>.fromList constructor

VectorList<T extends Vector>.fromList(
  1. List<T> list,
  2. int vectorLength, [
  3. int offset = 0,
  4. int stride = 0,
])

Create a new vector list from a list of vectors that have a size of vectorLength. Optionally it is possible to specify an offset in the buffer and a stride between each vector.

Implementation

VectorList.fromList(List<T> list, int vectorLength,
    [int offset = 0, int stride = 0])
    : _vectorLength = vectorLength,
      _offset = offset,
      _stride = stride == 0 ? vectorLength : stride,
      _length = list.length,
      _buffer = Float32List(
          offset + list.length * (stride == 0 ? vectorLength : stride)) {
  if (_stride < _vectorLength) {
    throw ArgumentError('Stride cannot be smaller than the vector size.');
  }
  for (var i = 0; i < _length; i++) {
    store(i, list[i]);
  }
}