
com.avsystem.commons.redis.util.FoldingBuilder.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-redis_2.11 Show documentation
Show all versions of commons-redis_2.11 Show documentation
AVSystem commons library for Scala
The newest version!
package com.avsystem.commons
package redis.util
import scala.collection.mutable
class FoldingBuilder[A, B](zero: B, fun: (B, A) => B) extends mutable.Builder[A, B] {
private[this] var res = zero
def +=(elem: A) = {
res = fun(res, elem)
this
}
def clear(): Unit = res = zero
def result(): B = res
}
object UnitBuilder extends mutable.Builder[Any, Unit] {
def +=(elem: Any) = this
def clear() = ()
def result() = ()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy