Updated on 2026-08-14

This commit is contained in:
Tangem 2025-02-20 12:53:26 +04:00
parent 6a5a8300cf
commit 3269095c97
15 changed files with 148 additions and 96 deletions

View file

@ -36,4 +36,16 @@ inline fun <T> Set<T>.addOrReplace(item: T, predicate: (T) -> Boolean): Set<T> {
}
return mutableList
}
inline fun <T> Set<T>.addOrReplace(items: Set<T>, predicate: (T, T) -> Boolean): Set<T> {
val updatedValues = this.toMutableSet()
items.forEach { newValue ->
val isReplaced = updatedValues.replaceBy(item = newValue, predicate = { predicate(it, newValue) })
if (!isReplaced) updatedValues.add(newValue)
}
return updatedValues
}