trait
      
      
        MapEqualityConstraints extends AnyRef
      
      
      
          
        
      
      
        
        
        
        
        
              Value Members
              - 
      
      
      
      
        final 
        def
      
      
        !=(arg0: Any): Boolean
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        ##(): Int
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        ==(arg0: Any): Boolean
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        asInstanceOf[T0]: T0
      
      
      
        
      
    
      
     - 
      
      
      
      
        
        def
      
      
        clone(): AnyRef
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        eq(arg0: AnyRef): Boolean
      
      
      
        
      
    
      
     - 
      
      
      
      
        
        def
      
      
        equals(arg0: Any): Boolean
      
      
      
        
      
    
      
     - 
      
      
      
      
        
        def
      
      
        finalize(): Unit
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        getClass(): Class[_]
      
      
      
        
      
    
      
     - 
      
      
      
      
        
        def
      
      
        hashCode(): Int
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        isInstanceOf[T0]: Boolean
      
      
      
        
      
    
      
     - 
      
      
      
      
        implicit 
        def
      
      
        mapEqualityConstraint[KA, VA, CA[ka, kb] <: GenMap[ka, kb], KB, VB, CB[kb, vb] <: GenMap[kb, vb]](implicit equalityOfA: Equality[CA[KA, VA]], evKey: CanEqual[KA, KB], evValue: CanEqual[VA, VB]): CanEqual[CA[KA, VA], CB[KB, VB]]
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        ne(arg0: AnyRef): Boolean
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        notify(): Unit
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        notifyAll(): Unit
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        synchronized[T0](arg0: ⇒ T0): T0
      
      
      
        
      
    
      
     - 
      
      
      
      
        
        def
      
      
        toString(): String
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        wait(): Unit
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        wait(arg0: Long, arg1: Int): Unit
      
      
      
        
      
    
      
     - 
      
      
      
      
        final 
        def
      
      
        wait(arg0: Long): Unit
      
      
      
        
      
    
      
     
             
        
        
         
        
        
              
Inherited from AnyRef
            
              
Inherited from Any
            
        
         
        
       
      
      
     
      
Provides an implicit method that loosens the equality constraint defined by
TypeCheckedTripleEqualsorConversionCheckedTripleEqualsfor ScalaMaps to one that more closely matches Scala's approach toMapequality.Scala's approach to
Mapequality is that if both objects being compared areMaps, the elements are compared to determine equality. This means you could compare an immutableTreeMapand a mutableHashMapfor equality, for instance, and get true so long as the two maps contained the same key-value mappings. Here's an example:scala> import scala.collection.immutable.TreeMap import scala.collection.immutable.TreeMap scala> import scala.collection.mutable.HashMap import scala.collection.mutable.HashMap scala> TreeMap("one" -> 1, "two" -> 2) == HashMap("one" -> 1, "two" -> 2) res0: Boolean = trueSuch a comparison would not, however, compile if you used
===under eitherTypeCheckedTripleEqualsorConversionCheckedTripleEquals, becauseTreeMapandHashMapare not in a subtype/supertype relationship, nor does an implicit conversion by default exist between them:scala> import org.scalactic._ import org.scalactic._ scala> import TypeCheckedTripleEquals._ import TypeCheckedTripleEquals._ scala> TreeMap("one" -> 1, "two" -> 2) === HashMap("one" -> 1, "two" -> 2) <console>:16: error: types scala.collection.immutable.TreeMap[String,Int] and scala.collection.mutable.HashMap[String,Int] do not adhere to the equality constraint selected for the === and !== operators; the missing implicit parameter is of type org.scalactic.EqualityConstraint[scala.collection.immutable.TreeMap[String,Int], scala.collection.mutable.HashMap[String,Int]] TreeMap("one" -> 1, "two" -> 2) === HashMap("one" -> 1, "two" -> 2) ^If you mix or import the implicit conversion provided by
MapEqualityConstraint, however, the comparison will be allowed:scala> import MapEqualityConstraints._ import MapEqualityConstraints._ scala> TreeMap("one" -> 1, "two" -> 2) === HashMap("one" -> 1, "two" -> 2) res2: Boolean = trueThe equality constraint provided by this trait requires that both left and right sides are subclasses of
scala.collection.GenMapand that anEqualityConstraintcan be found for both key types and both value types. In the example above, both theTreeMapandHashMapare subclasses ofscala.collection.GenMap, and the regularTypeCheckedTripleEqualsprovides equality constraints for the key types, both of which areString, and value types, both of which areInt. By contrast, this trait would not allow aTreeMap[String, Int]to be compared against aHashMap[String, java.util.Date], because no equality constraint will exist between the value typesIntandDate:scala> import java.util.Date import java.util.Date scala> TreeMap("one" -> 1, "two" -> 2) === HashMap("one" -> new Date, "two" -> new Date) <console>:20: error: types scala.collection.immutable.TreeMap[String,Int] and scala.collection.mutable.HashMap[String,java.util.Date] do not adhere to the equality constraint selected for the === and !== operators; the missing implicit parameter is of type org.scalactic.EqualityConstraint[scala.collection.immutable.TreeMap[String,Int], scala.collection.mutable.HashMap[String,java.util.Date]] TreeMap("one" -> 1, "two" -> 2) === HashMap("one" -> new Date, "two" -> new Date) ^