transform<S> method

Vector<S> transform<S>(
  1. S read(
    1. int index,
    2. T value
    ), {
  2. T write(
    1. int index,
    2. S value
    )?,
  3. DataType<S>? dataType,
})

Returns a view on this Vector with all its elements lazily converted by calling the provided read transformation. An optionally provided write transformation enables writing to the returned vector.

Implementation

Vector<S> transform<S>(S Function(int index, T value) read,
        {T Function(int index, S value)? write, DataType<S>? dataType}) =>
    TransformedVector<T, S>(
      this,
      read,
      write ?? (i, v) => throw UnsupportedError('Vector is not mutable.'),
      dataType ?? DataType.fromType<S>(),
    );