Float32x4List.sublistView constructor

  1. @Since("2.8")
Float32x4List.sublistView(
  1. TypedData data,
  2. [int start = 0,
  3. int? end]
)

Creates a Float32x4List view on a range of elements of data.

Creates a view on the range of data.buffer which corresponds to the elements of data from start until end. If data is a typed data list, like Uint16List, then the view is on the bytes of the elements with indices from start until end. If data is a ByteData, it's treated like a list of bytes.

If provided, start and end must satisfy

0 ≤ startendelementCount

where elementCount is the number of elements in data, which is the same as the List.length of a typed data list.

If omitted, start defaults to zero and end to elementCount.

The start and end indices of the range of bytes being viewed must be multiples of sixteen.

Implementation

@Since("2.8")
factory Float32x4List.sublistView(TypedData data, [int start = 0, int? end]) {
  int elementSize = data.elementSizeInBytes;
  end = RangeError.checkValidRange(
      start, end, data.lengthInBytes ~/ elementSize);
  if (end == null) throw "unreachable"; // TODO(38725)
  int byteLength = (end - start) * elementSize;
  if (byteLength % bytesPerElement != 0) {
    throw ArgumentError("The number of bytes to view must be a multiple of " +
        "$bytesPerElement");
  }
  return data.buffer.asFloat32x4List(data.offsetInBytes + start * elementSize,
      byteLength ~/ bytesPerElement);
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-typed_data/Float32x4List/Float32x4List.sublistView.html