Scala BitSet ++[B](that: GenTraversableOnce[B]) method with example
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: GenTraversableOnce[B])
method is utilised create a bitset containing the elements from the left hand operand followed by the elements from the right hand operand.
Method Definition: def ++[B](that: GenTraversableOnce[B])
Return Type: It returns a new bitset which contains all elements of this bitset.
Example #1:
// Scala program of Bitset ++ // method import scala.collection.immutable.BitSet // Creating object object GfG { // Main method def main(args : Array[String]) { val b 1 : BitSet = BitSet( 0 , 1 , 2 , 3 ) val b 2 = List( "a" , "B" ) // Applying BitSet ++() function val bs 1 = b 1 ++ b 2 // Displays output println(bs 1 ) } } |
chevron_right
filter_none
Output:
Set(0, 1, a, 2, B, 3)
Example #2:
// Scala program of Bitset ++ // method import scala.collection.immutable.BitSet // Creating object object GfG { // Main method def main(args : Array[String]) { val b 1 : BitSet = BitSet( 0 , 1 , 2 , 3 ) val b 2 = List( "A" ) // Applying BitSet ++() function val bs 1 = b 1 ++ b 2 // Displays output println(bs 1 ) } } |
chevron_right
filter_none
Output:
Set(0, 1, A, 2, 3)