Documentation / kotlin-core / com.femastudios.kotlin.core / kotlin.collections.Iterable

Extensions for kotlin.collections.Iterable

filterIndexedToSet

fun <T> Iterable<T>.filterIndexedToSet(predicate: (index: Int, T) -> Boolean): Set<T>

Returns a set containing only elements matching the given predicate.

filterIsInstanceToSet

fun <R> Iterable<*>.filterIsInstanceToSet(): Set<R>

Returns a set containing all elements that are instances of specified type parameter R.

fun <R> Iterable<*>.filterIsInstanceToSet(klass: Class<R>): Set<R>

Returns a set containing all elements that are instances of specified class.

filterNotNullToSet

fun <T : Any> Iterable<T?>.filterNotNullToSet(): Set<T>

Returns a set containing all elements that are not null.

filterNotToSet

fun <T> Iterable<T>.filterNotToSet(predicate: (T) -> Boolean): Set<T>

Returns a set containing all elements not matching the given predicate.

filterToSet

fun <T> Iterable<T>.filterToSet(predicate: (T) -> Boolean): Set<T>

Returns a set containing only elements matching the given predicate.

flatMapToSet

fun <T, R> Iterable<T>.flatMapToSet(transform: (T) -> Iterable<R>): Set<R>

Returns a set of all elements yielded from results of transform function being invoked on each element of original collection.

mapIndexedNotNullToSet

fun <T, R : Any> Iterable<T>.mapIndexedNotNullToSet(transform: (index: Int, T) -> R?): Set<R>

Returns a set containing only the non-null results of applying the given transform function to each element and its index in the original collection.

mapIndexedToSet

fun <T, R> Iterable<T>.mapIndexedToSet(transform: (index: Int, T) -> R): Set<R>

Returns a set containing the results of applying the given transform function to each element and its index in the original collection.

mapNotNullToSet

fun <T, R : Any> Iterable<T>.mapNotNullToSet(transform: (T) -> R?): Set<R>

Returns a set containing only the non-null results of applying the given transform function to each element in the original collection.

mapToSet

fun <T, R> Iterable<T>.mapToSet(transform: (T) -> R): Set<R>

Returns a set containing the results of applying the given transform function to each element in the original collection.

sorted

fun <T : Comparable<T>> Iterable<T>.sorted(descending: Boolean): List<T>

Returns a list of all elements sorted according to their natural sort order.

sortedBy

fun <I, C : Comparable<C>> Iterable<I>.sortedBy(descending: Boolean, selector: (I) -> C?): List<I>

Returns a list of all elements sorted according to natural sort order of the value returned by specified selector function.

toMap

fun <K, V> Iterable<Entry<K, V>>.toMap(): Map<K, V>

Returns a Map created from the given Map.Entry.

zipWith

fun <T, R> Iterable<T>.zipWith(pairProvider: (T) -> R): List<Pair<T, R>>

Returns a list of pairs built from the elements of this collection and the R generated by pairProvider.