In Scala mutable collections, SortedSet toBuffer() method is utilized to return a buffer consisting of all the elements of the SortedSet.
Method Definition: def toBuffer[B >: A]: Buffer[B]
Return Type: It returns a buffer consisting of all the elements of the SortedSet.
Example #1:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 1 , 2 , 3 , 4 , 5 )
val result = s 1 .toBuffer
for (elem < - result)
println(elem)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 41 , 12 , 23 , 43 , 1 , 72 )
val result = s 1 .toBuffer
for (elem < - result)
println(elem)
}
}
|