Scala Map vs HashMap

佐手、 提交于 2019-12-22 01:44:57

问题


Is there a difference between a Scala Map and a HashMap? I am using the scala.collection.immutable.HashMap.


回答1:


scala.collection.immutable.Map is the interface for immutable maps while scala.collection.immutable.HashMap is a concrete implementation.

Creating with Map() or Map.empty gives a special empty singleton map, with Map(a -> b) with up to 4 pairs yields specialized classes for such small maps, and 5 and upwards gives you scala.collection.immutable.HashMap



来源:https://stackoverflow.com/questions/31685236/scala-map-vs-hashmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!