Scala BitSet -(elems: Int*) method with example
Last Updated :
04 May, 2020
Scala Bitsets are sets of non-negative integers which are represented as variable-size arrays of bits packed into 64-bit words. The -(elems: Int*) method is utilised takes two or more elements to be removed.
Method Definition: def +()
Return Type: a new collection that contains all elements except one less occurrence of each of the given elements.
Example #1:
import scala.collection.immutable.BitSet
object GfG
{
def main(args : Array[String])
{
val b 2 : Set[Int] = BitSet( 5 , 6 , 7 , 55 , 56 , 57 ) - 55 - 56
println(b 2 )
}
}
|
Output:
BitSet(5, 6, 7, 57)
Example #2:
import scala.collection.immutable.BitSet
object GfG
{
def main(args : Array[String])
{
val b 2 : Set[Int] = BitSet( 5 , 6 , 7 ) - 5 - 6 - 0
println(b 2 )
}
}
|
Share your thoughts in the comments
Please Login to comment...