kotlin.collections.Arrays.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rapidpm-dynamic-cdi Show documentation
Show all versions of rapidpm-dynamic-cdi Show documentation
Dynamic Dependency Injection with different ways to manage the resolver-strategy
@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("ArraysKt")
package kotlin.collections
import java.util.*
/**
* Returns a single list of all elements from all arrays in the given array.
*/
public fun Array>.flatten(): List {
val result = ArrayList(sumBy { it.size })
for (element in this) {
result.addAll(element)
}
return result
}
/**
* Returns a pair of lists, where
* *first* list is built from the first values of each pair from this array,
* *second* list is built from the second values of each pair from this array.
*/
public fun Array>.unzip(): Pair, List> {
val listT = ArrayList(size)
val listR = ArrayList(size)
for (pair in this) {
listT.add(pair.first)
listR.add(pair.second)
}
return listT to listR
}