retainAll

inline fun <T> MutableIterable<T>.retainAll(elementsToRetain: Collection<T>): Boolean(source)

Removes, from an iterable, every element that does not belong to the provided collection.

This method calls MutableCollection.retainAll if this is a collection, and Iterators.retainAll otherwise.

Return

true if any element was removed from this

See also

Parameters

elementsToRetain

the elements to retain


inline fun <T> MutableIterator<T>.retainAll(elementsToRetain: Collection<T>): Boolean(source)

Traverses an iterator and removes every element that does not belong to the provided collection. The iterator will be left exhausted: its hasNext method will return false.

Return

true if any element was removed from this

See also

Parameters

elementsToRetain

the elements to retain