Document return value of removeAll and retainAll with predicate

#KT-32532 Fixed
This commit is contained in:
Ilya Gorbunov
2019-07-12 18:29:30 +03:00
parent 7d173ed385
commit 945e058586
@@ -151,11 +151,15 @@ public fun <T> MutableCollection<in T>.addAll(elements: Array<out T>): Boolean {
/**
* Removes all elements from this [MutableIterable] that match the given [predicate].
*
* @return `true` if any element was removed from this collection, or `false` when no elements were removed and collection was not modified.
*/
public fun <T> MutableIterable<T>.removeAll(predicate: (T) -> Boolean): Boolean = filterInPlace(predicate, true)
/**
* Retains only elements of this [MutableIterable] that match the given [predicate].
*
* @return `true` if any element was removed from this collection, or `false` when all elements were retained and collection was not modified.
*/
public fun <T> MutableIterable<T>.retainAll(predicate: (T) -> Boolean): Boolean = filterInPlace(predicate, false)
@@ -173,11 +177,15 @@ private fun <T> MutableIterable<T>.filterInPlace(predicate: (T) -> Boolean, pred
/**
* Removes all elements from this [MutableList] that match the given [predicate].
*
* @return `true` if any element was removed from this collection, or `false` when no elements were removed and collection was not modified.
*/
public fun <T> MutableList<T>.removeAll(predicate: (T) -> Boolean): Boolean = filterInPlace(predicate, true)
/**
* Retains only elements of this [MutableList] that match the given [predicate].
*
* @return `true` if any element was removed from this collection, or `false` when all elements were retained and collection was not modified.
*/
public fun <T> MutableList<T>.retainAll(predicate: (T) -> Boolean): Boolean = filterInPlace(predicate, false)