mirror of https://github.com/sbt/sbt.git
dry-up map creation
This commit is contained in:
parent
eb54e20c56
commit
ff4482064c
|
|
@ -47,14 +47,18 @@ object IvyGraphMLDependencies extends App {
|
|||
|
||||
def module(id: ModuleId): Module = modules(id)
|
||||
|
||||
lazy val dependencyMap: Map[ModuleId, Seq[Module]] = {
|
||||
lazy val dependencyMap: Map[ModuleId, Seq[Module]] =
|
||||
createMap(identity)
|
||||
|
||||
lazy val reverseDependencyMap: Map[ModuleId, Seq[Module]] =
|
||||
createMap { case (a, b) => (b, a) }
|
||||
|
||||
def createMap(bindingFor: ((ModuleId, ModuleId)) => (ModuleId, ModuleId)): Map[ModuleId, Seq[Module]] = {
|
||||
val m = new HashMap[ModuleId, MSet[Module]] with MultiMap[ModuleId, Module]
|
||||
edges.foreach { case (from, to) => m.addBinding(from, module(to)) }
|
||||
m.toMap.mapValues(_.toSeq.sortBy(_.id.idString))
|
||||
}
|
||||
lazy val reverseDependencyMap: Map[ModuleId, Seq[Module]] = {
|
||||
val m = new HashMap[ModuleId, MSet[Module]] with MultiMap[ModuleId, Module]
|
||||
edges.foreach { case (from, to) => m.addBinding(to, module(from)) }
|
||||
edges.foreach { entry =>
|
||||
val (f, t) = bindingFor(entry)
|
||||
m.addBinding(f, module(t))
|
||||
}
|
||||
m.toMap.mapValues(_.toSeq.sortBy(_.id.idString))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue