private[this]object MMMap extends HashMap[A, Set[B]] with MultiMap[A, B]
How convert it to immutable?
immutabilitymutablescalascala-collections
private[this]object MMMap extends HashMap[A, Set[B]] with MultiMap[A, B]
How convert it to immutable?
Best Answer
The immutable hierarchy doesn't contain a MultiMap, so you won't be able to use the converted structure with the same convenient syntax. But if you're happy to deal with key/valueset pairs, then:
If you just want a mutable
HashMap
, you can just usex.toMap
in 2.8 orcollection.immutable.Map(x.toList: _*)
in 2.7.But if you want the whole structure to be immutable--including the underlying set!--then you have to do more: you need to convert the sets along the way. In 2.8:
In 2.7: