mapIndexedTo<R, C extends KtMutableCollection<R>> method

C mapIndexedTo<R, C extends KtMutableCollection<R>>(
  1. C destination,
  2. R transform(
    1. int index,
    2. T
    )
)

Applies the given transform function to each element and its index in the original collection and appends the results to the given destination. @param transform function that takes the index of an element and the element itself and returns the result of the transform applied to the element.

Implementation

C mapIndexedTo<R, C extends KtMutableCollection<R>>(
    C destination, R Function(int index, T) transform) {
  var index = 0;
  for (final item in iter) {
    destination.add(transform(index++, item));
  }
  return destination;
}