filterNotTo

Common
JVM
JS
Native
1.0
inline fun <T, C : MutableCollection<in T>> Array<out T>.filterNotTo(
    destination: C,
    predicate: (T) -> Boolean
): C
inline fun <C : MutableCollection<in Byte>> ByteArray.filterNotTo(
    destination: C,
    predicate: (Byte) -> Boolean
): C
inline fun <C : MutableCollection<in Short>> ShortArray.filterNotTo(
    destination: C,
    predicate: (Short) -> Boolean
): C
inline fun <C : MutableCollection<in Int>> IntArray.filterNotTo(
    destination: C,
    predicate: (Int) -> Boolean
): C
inline fun <C : MutableCollection<in Long>> LongArray.filterNotTo(
    destination: C,
    predicate: (Long) -> Boolean
): C
inline fun <C : MutableCollection<in Float>> FloatArray.filterNotTo(
    destination: C,
    predicate: (Float) -> Boolean
): C
inline fun <C : MutableCollection<in Double>> DoubleArray.filterNotTo(
    destination: C,
    predicate: (Double) -> Boolean
): C
inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterNotTo(
    destination: C,
    predicate: (Boolean) -> Boolean
): C
inline fun <C : MutableCollection<in Char>> CharArray.filterNotTo(
    destination: C,
    predicate: (Char) -> Boolean
): C
inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(
    destination: C,
    predicate: (T) -> Boolean
): C
@ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UInt>> UIntArray.filterNotTo(
    destination: C,
    predicate: (UInt) -> Boolean
): C
@ExperimentalUnsignedTypes inline fun <C : MutableCollection<in ULong>> ULongArray.filterNotTo(
    destination: C,
    predicate: (ULong) -> Boolean
): C
@ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UByte>> UByteArray.filterNotTo(
    destination: C,
    predicate: (UByte) -> Boolean
): C
@ExperimentalUnsignedTypes inline fun <C : MutableCollection<in UShort>> UShortArray.filterNotTo(
    destination: C,
    predicate: (UShort) -> Boolean
): C

Appends all elements not matching the given predicate to the given destination.

Common
JVM
JS
Native
1.0
inline fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(
    destination: M,
    predicate: (Entry<K, V>) -> Boolean
): M

Appends all entries not matching the given predicate into the given destination.

import kotlin.test.*
import java.util.*

fun main(args: Array<String>) {
//sampleStart
val originalMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3)
val destinationMap = mutableMapOf("key40" to 40, "key50" to 50)

val filteredMap = originalMap.filterNotTo(destinationMap) { it.value < 3 }
//destination map instance has been updated
println("destinationMap === filteredMap is ${destinationMap === filteredMap}") // true
println(destinationMap) // {key40=40, key50=50, key3=3}
// original map has not changed
println(originalMap) // {key1=1, key2=2, key3=3}

val anotherDestinationMap = mutableMapOf("key40" to 40, "key50" to 50)
val matchAllPredicate: ((Map.Entry<String, Int>)) -> Boolean = { it.value > 0 }
val filteredMapWithEverythingMatched = originalMap.filterNotTo(anotherDestinationMap, matchAllPredicate)
println(filteredMapWithEverythingMatched) // {key40=40, key50=50}
//sampleEnd
}

Return the destination map.