Concrete Immutable Collection ClassesImmutable BitSetsList MapsContents

List Maps

A ListMap represents a map as a linked list of key-value pairs. In general, operations on a list map might have to iterate through the entire list. Thus, operations on a list map take time linear in the size of the map. In fact there is little usage for list maps in Scala because standard immutable maps are almost always faster. The only possible difference is if the map is for some reason constructed in such a way that the first elements in the list are selected much more often than the other elements.

scala> val map = scala.collection.immutable.ListMap(1->"one"2->"two")
map: scala.collection.immutable.ListMap[Int,java.lang.String] = 
   Map(1 -> one, 2 -> two)
scala> map(2)
res30: String = "two"

Next: Concrete Mutable Collection Classes


Concrete Immutable Collection ClassesImmutable BitSetsList MapsContents