VectorList<T extends Vector>.view constructor

VectorList<T extends Vector>.view(
  1. Float32List buffer,
  2. int vectorLength, [
  3. int offset = 0,
  4. int stride = 0,
])

Create a new vector list as a view of buffer for 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.view(Float32List buffer, int vectorLength,
    [int offset = 0, int stride = 0])
    : _vectorLength = vectorLength,
      _offset = offset,
      _stride = stride == 0 ? vectorLength : stride,
      _length = (buffer.length - math.max(0, offset - stride)) ~/
          (stride == 0 ? vectorLength : stride),
      _buffer = buffer {
  if (_stride < _vectorLength) {
    throw ArgumentError('Stride cannot be smaller than the vector size.');
  }
}