Skip to content

Instantly share code, notes, and snippets.

@frgomes
Created October 12, 2015 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frgomes/d26f7e32586a48857910 to your computer and use it in GitHub Desktop.
Save frgomes/d26f7e32586a48857910 to your computer and use it in GitHub Desktop.
Scala -- Using multimaps
import scala.collection.mutable.{ Map, HashMap, Set, MultiMap }
// val evictedModuleIDs: Seq[ModuleID] = ...
val evicteds: Map[String, Set[ModuleID]] =
(new HashMap[String, Set[ModuleID]] with MultiMap[String, ModuleID] /: evictedModuleIDs) {
case (acc, m) =>
val key = s"${m.organization}:${m.name}"
acc.addBinding(key, m)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment