sdk-common / com.tomtom.online.sdk.common.functional.collections / Iterables / map

map

@NonNull static fun <A : Any!, B : Any!> map(@NonNull iterable: MutableIterable<A>, @NonNull mapper: (A) -> B): MutableIterable<B>

Returns an iterable consisting of the results of applying the specified mapper to the elements of the given iterable. As the method is working directly with an iterable it needs to create one, thus it returns an ArrayList as an Iterable. If you want to get a different type please use Iterables#map(Iterable, Supplier, Function1) method instead.

Parameters

iterable - MutableIterable<A>: values that should be mapped with the mapping function

mapper - (A) -> B: function that performs mapping of values

- type of the elements of given iterable

- type of the elements of the returned iterable

Return
MutableIterable<B>: iterable of mapped elements

@NonNull static fun <A : Any!, B : Any!, C : MutableCollection<B>!> map(@NonNull iterable: MutableIterable<A>, @NonNull supplier: Supplier<out C>, @NonNull mapper: (A) -> B): C

Returns an iterable consisting of the results of applying the specified mapper to the elements of the given iterable. It's possible to specify what underlying Iterable implementation should be returned as a result.

Parameters

iterable - MutableIterable<A>: elements that should be mapped with the mapping function

mapper - (A) -> B: function that performs mapping of elements

supplier - Supplier<out C>: supplier capable of returning the resulting iterable

- type of the elements of given iterable

- type of the elements of the returned iterable

- Type of collection to be returned

Return
C: iterable of mapped elements