Scala Mutable SortedSet find() method Last Updated : 26 Mar, 2020 Comments Improve Suggest changes Like Article Like Report In Scala mutable collections, SortedSet find() method is utilized to find the first element of the SortedSet that satisfies the given predicate if present. Method Definition: def find(p: (A) => Boolean): Option[A] Return Type: It returns the first element of the SortedSet which satisfies the given predicate. Example #1: Scala // Scala program of find() // method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(115, 112, 3, 113) // Applying find method val result = s1.find(_ == 3) // Displays output println(result) } } Output: Some(3) Example #2: Scala // Scala program of find() // method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(25, 22, 33, 13) // Applying find method val result = s1.find(_ == 10) // Displays output println(result) } } Output: None Comment More infoAdvertise with us Next Article Scala Mutable SortedSet find() method S Shivam_k Follow Improve Article Tags : Python Scala Scala Scala-Method Scala mutable-sortedset +1 More Practice Tags : python Similar Reads 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 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 filter() method In Scala mutable collections, SortedSet filter() method is utilized to select all elements of the SortedSet which satisfies a stated predicate. Method Definition: def filter(p: (A) => Boolean): SortedSet[A] Return Type: It returns a TreeSet containing all the elements of the SortedSet which satis 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 Scala mutable SortedSet ++() method 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 sca 1 min read Scala Mutable SortedSet head() method In Scala mutable collections, SortedSet head() method is utilized to display the first element of the SortedSet. Method Definition: def head: A Return Type: It returns the first element of the SortedSet. Example #1: Scala // Scala program of head() // method import scala.collection.mutable.SortedSet 1 min read Scala mutable SortedSet diff() method In Scala mutable collection, diff() method is utilized to compute the difference of a SortedSet and an another SortedSet. Method Definition: def diff(that: SortedSet[A]): SortedSet[A] Return Type: It returns a SortedSet which is the difference between two SortedSets. Example #1: Scala // Scala progr 1 min read Scala mutable SortedSet drop() method In scala mutable collection, drop() method is utilized to delete the first ânâ elements or to return all elements except first 'n' elements. Method Definition: def drop(n: Int): SortedSet[A]] Return Type: It returns all elements except first 'n' elements. Example #1: Scala // Scala program of drop() 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 &() 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 Like