DataFabricRus / textfile-utils

A simple JVM library with utilitarian methods for working with text files of any size, including merge sorting and binary search. The library is based on the Java NIO and Kotlin coroutines.
Apache License 2.0
3 stars 1 forks source link

replace `ResourceIterator` with `AutoCloseableSequence` ? #2

Closed sszuev closed 1 year ago

sszuev commented 1 year ago

Example:

class AutoCloseableSequenceImpl<X>(private val source: Iterator<X>): Sequence<X>, AutoCloseable {
    override fun iterator(): Iterator<X> = source

    override fun close() {
        TODO("Not yet implemented")
    }
}

fun <T, R> AutoCloseableSequenceImpl<T>.map(transform: (T) -> R): AutoCloseableSequenceImpl<R> {
    val theSequence = this as Sequence<T>
    return AutoCloseableSequenceImpl(theSequence.map(transform).iterator())
}
sszuev commented 1 year ago

We can't control every method of Sequence. No worth to do.

sszuev commented 10 months ago

ResourceIterator is now a separated lib: https://github.com/DataFabricRus/resource-iterator