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 function.
TreeSet(1, 4, 9, 16, 25)
TreeSet(1, 2, 6)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.