
better.files.package.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of better-files_2.11 Show documentation
Show all versions of better-files_2.11 Show documentation
Simple, safe and intuitive I/O in Scala
package better
import scala.collection.mutable
package object files extends Implicits {
type Files = Iterator[File]
type Closeable = {
def close(): Unit
}
type ManagedResource[A <: Closeable] = Traversable[A]
// Some utils:
private[files] def newMultiMap[A, B]: mutable.MultiMap[A, B] = new mutable.HashMap[A, mutable.Set[B]] with mutable.MultiMap[A, B]
@inline private[files] def when[A](condition: Boolean)(f: => A): Option[A] = if (condition) Some(f) else None
@inline private[files] def repeat(n: Int)(f: => Unit): Unit = (1 to n).foreach(_ => f)
private[files] def produce[A](f: => A) = new {
def till(hasMore: => Boolean): Iterator[A] = new Iterator[A] {
override def hasNext = hasMore
override def next() = f
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy