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

replaceAll

@NonNull static fun <A : Any!> replaceAll(@NonNull elements: MutableList<A>, @NonNull predicate: Predicate<A>, @NonNull replacement: A): MutableList<A>

Replaces elements that satisfies the given predicate, in the given list, with given replacement. Values that do not satisfy the predicate are left unchanged.

Parameters

elements - MutableList<A>: List of values.

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

replacement - A: Replacement value.

- Lists elements type.

Return
MutableList<A>: A new list, with all elements satisfying the predicate replaced by the new element.