code example:
Package com.dt.scala.datasetobject set_map { def main (args: Array[String]) : unit = { // set the collection, the data in the collection is non-repeatable. But the data is unordered. val dataset = set (1,2,5,4,1,3,2) println (dataSet ) val dataset2 = dataset.+ (1) //add elements to the collection, Generate another collection val dataset3 = dataset.++ (DataSet2) // Two collection merge, return new collection import scala.collection.mutable // Define variable collection val data = mutable. set.empty[int] data += 1 //adding elements to the collection data ++=list (3,4) // add elements from the list to the collection println (data) // ordered set treeset &Nbsp;import scala.collection.immutable val ts = immutable. TreeSet (1,3,2,5,2,3,9,7) println (TS) //treeset (1, 2, 3, 5, 7,  9) //variable treeset val mts = mutable. Treeset[int] () mts.add (1) //add a list to TreeSet mts.++= (List (1,2,3,9,7,5)) println (MTS) //TreeMap mapping, sorting values by default val tmap = Immutable. TreeMap ("Spark"->10, "Hadoop"->5, "Yarn"->8) println ( TMap) }}
This article is from the "Ding Dong" blog, please be sure to keep this source http://lqding.blog.51cto.com/9123978/1742099
40th: Set, Map, TreeSet, treemap operation code Combat