grizzled.io.MultiSource.scala Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of grizzled-scala_2.13.0-M5 Show documentation
                Show all versions of grizzled-scala_2.13.0-M5 Show documentation
A general-purpose Scala utility library
                
             The newest version!
        
        package grizzled.io
import scala.io.Source
import scala.collection.compat._
/** A `MultiSource` contains multiple `scala.io.Source`
  * objects and satisfies reads from them serially. Once composed, a
  * `MultiSource` can be used anywhere a `Source` is used.
  *
  * @param sources  the sources to wrap
  */
class MultiSource(sources: List[Source]) extends Source {
  /** Version of constructor that takes multiple arguments, instead of a list.
    *
    * @param sources  the sources to wrap
    */
  def this(sources: Source*) = this(sources.toList)
  /** The actual iterator.
    */
  protected val iter: Iterator[Char] = {
    sources.map(_.iterator).foldLeft(Iterator[Char]())(_ ++ _)
  }
  /** Reset, returning a new source.
    */
  override def reset: Source = new MultiSource(sources.map(_.reset()))
}
    © 2015 - 2025 Weber Informatics LLC | Privacy Policy