All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scalatra.util.MultiMapHeadView.scala Maven / Gradle / Ivy

The newest version!
package org.scalatra.util

import scala.collection.immutable.Map

trait MultiMapHeadView[A, B] extends Map[A, B] {
  protected def multiMap: Map[A, Seq[B]]

  override def get(key: A) = multiMap.get(key) flatMap { _.headOption }
  override def size = multiMap.size
  override def iterator = multiMap map { case(k, v) => (k, v.head) } iterator
  override def -(key: A) = Map() ++ this - key
  override def +[B1 >: B](kv: (A, B1)) = Map() ++ this + kv
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy