Scala Mutable SortedSet toMap() method Last Updated : 26 Mar, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In Scala mutable collections, toMap() method is utilized to return a map consisting of all the elements of the SortedSet. Method Definition: def toMap[T, U]: Map[T, U] Return Type: It returns a map consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toMap() // method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet((1, 2), (3, 4), (5, 6)) // Applying toMap method val result = s1.toMap // Display output println(result) } } Output: Map(1 -> 2, 3 -> 4, 5 -> 6) Example #2: Scala // Scala program of toMap() // method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet((12, 2), (13, 4), (15, 6)) // Applying toMap method val result = s1.toMap // Display output println(result) } } Output: Map(12 -> 2, 13 -> 4, 15 -> 6) Comment More infoAdvertise with us Next Article Scala Mutable SortedSet take() method S Shivam_k Follow Improve Article Tags : Scala Scala Scala-Method Scala mutable-sortedset Similar Reads Scala Mutable SortedSet take() method In Scala mutable collections, take() method is utilized to return a SortedSet consisting of first 'n' elements of the SortedSet. Method Definition: def take(n: Int): SortedSet[A] Where 'n' is specifies the number of element to select. Return Type: It returns a SortedSet consisting of first 'n' eleme 1 min read Scala Mutable SortedSet tail() method In Scala mutable collections, tail() method is utilized to return a SortedSet consisting of all the elements except the first element of the SortedSet. Method Definition: def tail: SortedSet[A] Return Type: It returns a SortedSet consisting of all the elements except the first element of the SortedS 1 min read Scala Mutable SortedSet toSeq() method In Scala mutable collections, SortedSet toSeq() method is utilized to return a seq consisting of all the elements of the SortedSet. Method Definition: def toSeq: Seq[A] Return Type: It returns a seq consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toSeq() // met 1 min read Scala Mutable SortedSet toArray() method In Scala mutable collections, toArray() is utilized to return an array consisting of all the elements of the SortedSet. Method Definition: def toArray: Array[A] Return Type: It returns an array consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toArray() // method 1 min read Scala Mutable SortedSet -() method In Scala mutable collections, SortedSet -() method is utilized to creates a new SortedSet with a given element removed from the SortedSet. Method Definition: def -(elem: A): SortedSet[A] Return Type: It returns a new SortedSet with a given element removed from the SortedSet. Example #1: Scala // Sca 1 min read Scala Mutable SortedSet +() method In Scala mutable collections, +() method is utilized to create a new SortedSet with an additional element unless the element is already present. Method Definition: def +(elem: A): SortedSet[A] Return Type: It returns a new SortedSet with an additional element unless the element is already present. E 1 min read Like