Scala mutable SortedSet ++() method Last Updated : 22 Apr, 2020 Comments Improve Suggest changes Like Article Like Report In Scala mutable collection, ++() method is utilized to add elements of one SortedSet to another SortedSet. Method Definition: def ++(elems: A): SortedSet[A] Return Type: It returns a new TreeSet containing elements of both the SortedSets. Example #1: Scala // Scala program of ++() method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(1, 3, 5) val s2 = SortedSet(2, 4, 6) // Applying ++() method val result = s1 ++ s2 // Display output print(result) } } Output: TreeSet(1, 2, 3, 4, 5, 6) Example #2: Scala // Scala program of ++() method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(41, 12, 23, 43, 1, 72) val s2 = SortedSet(1, 100, 5, 12, 23) // Applying ++() method val result = s1 ++ s2 // Display output print(result) } } Output: TreeSet(1, 5, 12, 23, 41, 43, 72, 100) Comment More infoAdvertise with us Next Article Scala mutable SortedSet ++() method S Shivam_k Follow Improve Article Tags : Python Scala Scala Mutable-collections Scala mutable-sortedset Practice Tags : python Similar Reads 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 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 collection &~() method is utilized to create a new SortedSet consisting of elements after the difference between two given SortedSets. Method Definition: def &~(that: SortedSet[A]): SortedSet[A] Return Type: It returns a TreeSet consisting of elements after the difference be 1 min read Scala mutable SortedSet &() method In Scala mutable collection, &() method is utilized to create a new SortedSet consisting of all elements that are present in both the given SortedSets. Method Definition: def &(that: SortedSet[A]): SortedSet[A] Return Type: It returns a new SortedSet consisting of all elements that are prese 1 min read Scala Mutable SortedSet map() method In Scala mutable collections, map() method is utilized to build a new SortedSet by applying a function to all elements of this SortedSet. Method Definition: def map[B](f: (A) => B): mutable.SortedSet[B] Return Type: It returns a new SortedSet containing all the elements after applying the given f 1 min read Scala Mutable SortedSet sum() method In Scala mutable collections, sum() method is utilized to find the sum of all the elements of the SortedSet. Method Definition: def sum: A Return Type: It returns the sum of all the elements of the SortedSet. Example #1: Scala // Scala program of sum() // method import scala.collection.mutable.Sorte 1 min read Scala Mutable SortedSet max() method In Scala mutable collections, max() method is utilized to find the largest element of all the elements in the SortedSet. Method Definition: def max: A Return Type: It returns the largest of all the elements in the SortedSet. Example #1: Scala // Scala program of max() // method import scala.collecti 1 min read Scala Mutable SortedSet min() method In Scala mutable collections, min() method is utilized to find the smallest element of all the elements in the stated list. Method Definition: def min: A Return Type: It returns the smallest of all the elements in the stated list. Example #1: Scala // Scala program of min() // method import scala.co 1 min read 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 init() method In Scala mutable collections, SortedSet init() method is utilized to find all the elements of the SortedSet except the last one. Method Definition: def init: SortedSet[A] Return Type: It returns all the elements of the SortedSet except the last one. Example #1: Scala // Scala program of init() // me 1 min read Like