
name.remal.kotlin.sequences.Sequence.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
Java & Kotlin tools: common
The newest version!
package name.remal
import java.util.SortedMap
fun Sequence.toMutableMap(keyExtractor: (value: V) -> K): MutableMap = mutableMapOf().also {
for (value in this) {
val key = keyExtractor(value)
it[key] = value
}
}
fun Sequence.toMap(keyExtractor: (value: V) -> K): Map = toMutableMap(keyExtractor).toMap()
fun Sequence.toHashMap(keyExtractor: (value: V) -> K): MutableMap = hashMapOf().also {
for (value in this) {
val key = keyExtractor(value)
it[key] = value
}
}
fun > Sequence.toSortedMap(keyExtractor: (value: V) -> K): SortedMap = sortedMapOf().also {
for (value in this) {
val key = keyExtractor(value)
it[key] = value
}
}
fun Sequence.toStream() = iterator().asStream()
© 2015 - 2025 Weber Informatics LLC | Privacy Policy