Scala Bitsets are sets of non-negative integers which are represented as variable-size arrays of bits packed into 64-bit words. The ++:[B](that: TraversableOnce[B]) method is utilised create a collection containing the elements from the left hand operand followed by the elements from the right hand operand.
Method Definition: def ++:[B](that: TraversableOnce[B])
Return Type: It returns a new bitset which contains all elements of this bitset followed by all elements of that.
Example #1:
// Scala program of Bitset ++ // method import scala.collection.immutable.BitSet
import scala.collection.mutable.LinkedList
// Creating object object GfG
{ // Main method
def main(args : Array[String])
{
val b 1 = BitSet( 0 , 1 , 2 , 3 )
val b 2 = LinkedList( 100 )
// Applying BitSet ++() function
val bs 1 = b 1 ++ : b 2
// Displays output
println(bs 1 )
}
} |
Output:
LinkedList(0, 1, 2, 3, 100)
Example #2:
// Scala program of Bitset ++ // method import scala.collection.immutable.BitSet
import scala.collection.mutable.LinkedList
// Creating object object GfG
{ // Main method
def main(args : Array[String])
{
val b 1 = BitSet( 11 , 22 , 33 )
val b 2 = LinkedList( "A" , "B" )
// Applying BitSet ++() function
val bs 1 = b 1 ++ : b 2
// Displays output
println(bs 1 )
}
} |
Output:
LinkedList(0, 1, 2, 3, A, B)