kotlin.collections.distinctBy

distinctBy

inline fun <T, K> Iterable<T>.distinctBy(
    selector: (T) -> K
): List<T>

Returns a list containing only elements from the given collection having distinct keys returned by the given selector function.

The elements in the resulting list are in the same order as they were in the source collection.

inline fun <T, K> Array<out T>.distinctBy(
    selector: (T) -> K
): List<T>
inline fun <K> ByteArray.distinctBy(
    selector: (Byte) -> K
): List<Byte>
inline fun <K> ShortArray.distinctBy(
    selector: (Short) -> K
): List<Short>
inline fun <K> IntArray.distinctBy(
    selector: (Int) -> K
): List<Int>
inline fun <K> LongArray.distinctBy(
    selector: (Long) -> K
): List<Long>
inline fun <K> FloatArray.distinctBy(
    selector: (Float) -> K
): List<Float>
inline fun <K> DoubleArray.distinctBy(
    selector: (Double) -> K
): List<Double>
inline fun <K> BooleanArray.distinctBy(
    selector: (Boolean) -> K
): List<Boolean>
inline fun <K> CharArray.distinctBy(
    selector: (Char) -> K
): List<Char>

Returns a list containing only elements from the given array having distinct keys returned by the given selector function.

The elements in the resulting list are in the same order as they were in the source array.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/distinct-by.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部