8.32. Scala Mapping

发布时间 : 2025-10-25 13:35:11 UTC      

Page Views: 9 views

mapping is an iterative key-value pair (key/value) structure.

All values can be obtained by key.

The keys in Map are unique.

Map also known as Hash tables.

Map has two types, mutable and immutable, the difference is that a mutable object can modify it, while an immutable object cannot.

Scala usage is immutable by default Map . If you need to use mutable sets, you need to explicitly introduce import scala.collection.mutable.Map Class

In Scala, you can use both mutable and immutable. Map immutable direct use Map , variable use mutable.Map . The following example demonstrates immutability Map application:

// An empty hash table with keys as strings and values as integers var A:Map[Char,Int] = Map() // Map Key Value Pair Demonstration val colors = Map("red" -> "#FF0000", "azure" -> "#F0FFFF") 

Define Map you need to define a type for the key-value pair. If you need to add key-value , you can use the + sign, as follows:

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。