Scala BitSet equals() 方法与示例
Scala 位集是一组非负整数,它们表示为打包成 64 位字的可变大小的位数组。 equals() 方法将此集合与另一个对象进行比较以获得相等性。
Method Definition: def equals()
Return Type: It returns true if that is a set which contains the same elements as this set.
示例 #1:
// Scala program of equals()
// method
import scala.collection.immutable.BitSet
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Creating BitSet
val s1 = BitSet(1, 2, 3, 4, 5)
val s2 = BitSet(5, 2, 3, 1, 4)
// Applying equals method
val result = s1.equals(s2)
// Displays output
println(result)
}
}
输出:
true
示例 #2:
// Scala program of equals()
// method
import scala.collection.immutable.BitSet
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Creating BitSet
val s1 = BitSet(11, 10, 2019)
val s2 = BitSet(9, 10, 2018)
// Applying equals method
val result = s1.equals(s2)
// Displays output
println(result)
}
}
输出:
false