In Scala immutable
TreeSet class, the dropWhile() method is utilized to drop the longest prefix from the front which satisfies a given predicate in a TreeSet.
Method Definition: def dropWhile(p: (A) => Boolean): TreeSet[A]
Return Type: It returns a new TreeSet that consists of elements after dropping the longest prefix satisfying the given predicate.
TreeSet(2, 4, 6, 7, 8, 9) TreeSet after using dropWhile() method: TreeSet(7, 8, 9)
TreeSet(3, 5, 6, 7, 8, 9) TreeSet after using dropWhile() method: TreeSet(6, 7, 8, 9)
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.