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:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 1 , 2 , 3 , 4 , 5 )
val s 2 = SortedSet( 1 , 2 , 3 )
val s 3 = s 1 .diff(s 2 )
for (elem < - s 3 )
println(elem)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 1 , 2 , 3 , 4 , 5 )
val s 2 = SortedSet( 6 , 2 , 7 , 8 )
val s 3 = s 1 .diff(s 2 )
for (elem < - s 3 )
println(elem)
}
}
|