Scala BitSet equals() method with example
Last Updated :
22 Dec, 2022
Scala Bitsets are sets of non-negative integers which are represented as variable-size arrays of bits packed into 64-bit words. The equals() method compares this set with another object for equality.
Method Definition: def equals() Return Type: It returns true if that is a set which contains the same elements as this set.
Example #1:
Scala
import scala.collection.immutable.BitSet
object GfG
{
def main(args : Array[String])
{
val s 1 = BitSet( 1 , 2 , 3 , 4 , 5 )
val s 2 = BitSet( 5 , 2 , 3 , 1 , 4 )
val result = s 1 .equals(s 2 )
println(result)
}
}
|
Example #2:
Scala
import scala.collection.immutable.BitSet
object GfG
{
def main(args : Array[String])
{
val s 1 = BitSet( 11 , 10 , 2019 )
val s 2 = BitSet( 9 , 10 , 2018 )
val result = s 1 .equals(s 2 )
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...