casualjim
8/24/2011 - 3:58 PM

gistfile1.scala

object MultiMap {

  type Coll = MultiMap

  def apply(elems: (String, Seq[String])*): MultiMap = (newBuilder ++= elems).result

  def newBuilder: Builder[(String, Seq[String]), MultiMap] = new MapBuilder[String, Seq[String], MultiMap](empty)

  implicit def canBuildFrom: CanBuildFrom[Map[String, Seq[String]], (String, Seq[String]), MultiMap] = {
    new CanBuildFrom[Map[String, Seq[String]], (String, Seq[String]), MultiMap] {
      def apply(from: Map[String, Seq[String]]) = newBuilder

      def apply() = newBuilder
    }
  }
  def empty = new MultiMap()
}