sdk-common / com.tomtom.online.sdk.common.functional.collections / Lists / conditionalMap

conditionalMap

@NonNull static fun <A : Any!> conditionalMap(@NonNull list: MutableList<A>, @NonNull predicate: Predicate<A>, @NonNull mapper: (A) -> A): MutableList<A>

Performs a conditional map on the given list. Runs a given mapper function for every list element that satisfies the given predicate. Values that do not satisfy the predicate are returned without any change.

Parameters

list - MutableList<A>: list of values that should be conditionally mapped

predicate - Predicate<A>: predicate that needs to be satisfied

mapper - (A) -> A: function that will be run for each element that satisfies the predicate

- type of the list elements

Return
MutableList<A>: list of mapped elements.