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

map

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

Returns a set consisting of the results of applying the specified mapper to the elements of the given set. As the method is working directly with Set it needs to create one, thus it returns a HashSet as a Set. Sets#map(Set, Supplier, Function1) method instead.

Parameters

set - MutableSet<A>: Values that should be mapped with the mapping function.

mapper - (A) -> B: Function that performs the mapping of values.

- Type of the elements of a given set.

- Type of the elements of the returned set.

Return
MutableSet<B>: The set of mapped elements.

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

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

Parameters

set - MutableSet<A>: Elements that should be mapped with the mapping function.

mapper - (A) -> B: Function that performs the mapping of elements.

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

- Type of the elements of a given set.

- Type of the elements of the returned iterable.

- Type of collection to be returned.

Return
C: The collection of mapped elements.