Provides an equality constraint that allows two subtypes of scala.collection.GenSet
s to be compared for equality with ===
so long
as an EqualityConstraint
is available for the element types.
Provides an equality constraint that allows two subtypes of scala.collection.GenSet
s to be compared for equality with ===
so long
as an EqualityConstraint
is available for the element types.
Provides an implicit method that loosens the equality constraint defined by
TypeCheckedTripleEquals
orConversionCheckedTripleEquals
for ScalaSet
s to one that more closely matches Scala's approach toSet
equality.Scala's approach to
Set
equality is that if both objects being compared areSet
s, the elements are compared to determine equality. This means you could compare an immutableTreeSet
and a mutableHashSet
for equality, for instance, and get true so long as the twoSet
s contained the same elements in the same order. Here's an example:Such a comparison would not, however, compile if you used
===
under eitherTypeCheckedTripleEquals
orConversionCheckedTripleEquals
, becauseTreeSet
andHashSet
are not in a subtype/supertype relationship, nor does an implicit conversion by default exist between them:If you mix or import the implicit conversion provided by
SetEqualityConstraint
, however, the comparison will be allowed:The equality constraint provided by this trait requires that both left and right sides are subclasses of
scala.collection.GenSet
and that anEqualityConstraint
can be found for the element types. In the example above, both theTreeSet
andHashSet
are subclasses ofscala.collection.GenSet
, and the regularTypeCheckedTripleEquals
provides equality constraints for the element types, both of which areInt
. By contrast, this trait would not allow aTreeSet[Int]
to be compared against aHashSet[java.util.Date]
, because no equality constraint will exist between the element typesInt
andDate
: