Scala BitSet count() 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 count() method is utilised to count the number of elements in the traversable or iterator
Method Definition: def count()
Return Type: It returns the count of elements
Example #1:
import scala.collection.immutable.BitSet
object GfG
{
def main(args : Array[String])
{
val s 1 = BitSet( 1 , 2 , 3 , 4 , 5 )
val result = s 1 .count(z => true )
println(result)
}
}
|
Example #2:
import scala.collection.immutable.BitSet
object GfG
{
def main(args : Array[String])
{
val s 1 = BitSet( 11 , 22 , 33 )
val result = s 1 .count(z => true )
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...