[NI] Add feature for choosing candidate by lambda return type
This commit is contained in:
@@ -148,4 +148,17 @@ inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapToNullable(des
|
||||
}
|
||||
|
||||
fun <E : Enum<E>> min(a: E, b: E): E = if (a < b) a else b
|
||||
fun <E : Comparable<E>> min(a: E, b: E): E = if (a < b) a else b
|
||||
fun <E : Comparable<E>> min(a: E, b: E): E = if (a < b) a else b
|
||||
|
||||
inline fun <T, R> Iterable<T>.same(extractor: (T) -> R): Boolean {
|
||||
val iterator = iterator()
|
||||
val firstValue = extractor(iterator.next())
|
||||
while (iterator.hasNext()) {
|
||||
val item = iterator.next()
|
||||
val value = extractor(item)
|
||||
if (value != firstValue) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user